Node.js 反应组件不';不是在Heroku上出现而是在本地

Node.js 反应组件不';不是在Heroku上出现而是在本地,node.js,reactjs,heroku,Node.js,Reactjs,Heroku,我试图在heroku上部署我的react应用程序,但只显示index.html,没有显示所有组件。该应用程序在本地主机上运行良好。我制作了一个form.js,用于为NodeEmailer创建服务器 我的目录看起来像 src - index.js form.js package.json mypackage.json { "name": "earthly", "version": "0.1.0", "private": true, "proxy": "http://localhost:

我试图在heroku上部署我的react应用程序,但只显示index.html,没有显示所有组件。该应用程序在本地主机上运行良好。我制作了一个form.js,用于为NodeEmailer创建服务器

我的目录看起来像

src
 - index.js
form.js
package.json
mypackage.json

{
 "name": "earthly",
 "version": "0.1.0",
 "private": true,
 "proxy": "http://localhost:3001",
 "engines": {
 "node": "8.11.1",
 "npm": "6.2.0"
},
 "dependencies": {
 "axios": "^0.18.0",
 "body-parser": "^1.18.3",
 "concurrently": "^3.6.0",
 "data.js": "^0.11.5",
 "express": "^4.16.3",
 "nodemailer": "^4.6.7",
 "nodemon": "^1.18.3",
 "npm": "^6.2.0",
 "react": "^16.4.1",
 "react-dom": "^16.4.1",
 "react-router-dom": "^4.3.1",
 "react-scripts": "1.1.4",
 "react-stripe-checkout": "^2.6.3",
 "react-stripe-elements": "^2.0.1",
 "reactstrap": "^6.3.0"
},
"scripts": {
"start": "concurrently \"cross-env NODE_PATH=src react- 
scripts start\" \"node index.js\"",
"server": "nodemon form.js",
"dev": "npm run server",
"build": "react-scripts build",
"test": "cross-env NODE_PATH=src react-scripts test -- 
env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"cross-env": "^5.2.0"
},
form.js

app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res) {
res.sendFile('index.html');
});

app.listen(process.env.PORT, '0.0.0.0', function(err) {
console.log("Started listening on %s", app.url);
});
在Heroku上建立日志

Node.js app detected
-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_VERBOSE=false
   NODE_ENV=production
   NODE_MODULES_CACHE=true
-----> Installing binaries
   engines.node (package.json):  8.11.1
   engines.npm (package.json):   6.2.0

   Resolving node version 8.11.1...
   Downloading and installing node 8.11.1...
   Bootstrapping npm 6.2.0 (replacing 5.6.0)...
   npm 6.2.0 installed
-----> Restoring cache
   Loading 2 from cacheDirectories (default):
   - node_modules
   - bower_components (not cached - skipping)
-----> Building dependencies
   Installing node modules (package.json + package-lock)
   audited 21180 packages in 16.791s
   found 20 moderate severity vulnerabilities
   run `npm audit fix` to fix them, or `npm audit` for 
details
-----> Caching build
   Clearing previous node cache
   Saving 2 cacheDirectories (default):
   - node_modules
   - bower_components (nothing to cache)
-----> Pruning devDependencies
   removed 3 packages and audited 21170 packages in 
14.867s
   found 20 moderate severity vulnerabilities
   run `npm audit fix` to fix them, or `npm audit` for 
details
-----> Build succeeded!
-----> Discovering process types
   Procfile declares types -> react, web
-----> Compressing...
   Done: 62.6M
-----> Launching...
   Released v45
   https://earthly.herokuapp.com/ deployed to Heroku

我是一名学生,这是我第一次用react和heroku制作应用程序,所以我不知道该怎么做。如果有人能帮忙,我们将不胜感激!谢谢。

没有“组件”是什么意思?它不是在index.html中加载index.js吗?另外,您能显示您的procfile和index.html文件吗?不,它没有加载index.js。但是我把它修好了。我必须删除我的devdependency并在脚本上添加“heroku postbuild”:“NODE_PATH=src react scripts build”。同样在form.js上,我添加了app.use(express.static(uu dirname+'/build');app.listen(process.env.PORT,“0.0.0.0”,函数(err){console.log(“在%s上开始侦听”,app.url);});谢谢你,凯尔!