使用旧的package.json脚本的heroku

时间:2018-10-07 23:51:34

标签: javascript reactjs heroku

我已经使用create-react-app创建了一个项目,到目前为止,它一直运行良好。我一直在使用服务器上的开发环境进行测试,但是当尝试更新到生产环境时,heroku遇到了问题。

在package.json中设置旧脚本的方式是

"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",

这是开箱即用的,我将其更改为:

"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",

因此,在本地测试时,我只运行dev脚本,但从理论上讲,heroku应该运行start,这将仅用于静态包。

但是,当上传此仓库并尝试访问heroku部署时,它会一直说:

2018-10-07T23:25:32.713677+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-07T23:26:01.642730+00:00 heroku[web.1]: Starting process with command `npm start`
2018-10-07T23:26:04.564689+00:00 app[web.1]: 
2018-10-07T23:26:04.564714+00:00 app[web.1]: > reactdemo@0.1.0 start /app
2018-10-07T23:26:04.564716+00:00 app[web.1]: > react-scripts start
2018-10-07T23:26:04.564717+00:00 app[web.1]: 
2018-10-07T23:26:07.169514+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-07T23:26:07.171554+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-07T23:26:07.154434+00:00 heroku[web.1]: Process exited with status 1
2018-10-07T23:26:07.023754+00:00 app[web.1]: module.js:550
2018-10-07T23:26:07.023769+00:00 app[web.1]: throw err;
2018-10-07T23:26:07.023771+00:00 app[web.1]: ^
2018-10-07T23:26:07.023772+00:00 app[web.1]: 
2018-10-07T23:26:07.023774+00:00 app[web.1]: Error: Cannot find module 'webpack'
2018-10-07T23:26:07.023776+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:548:15)
2018-10-07T23:26:07.023777+00:00 app[web.1]: at Function.Module._load (module.js:475:25)
2018-10-07T23:26:07.023778+00:00 app[web.1]: at Module.require (module.js:597:17)
2018-10-07T23:26:07.023780+00:00 app[web.1]: at require (internal/module.js:11:18)

现在(实际上,据我所知)这个问题确实是在更新后,heroku正在运行旧的package.json脚本,因为它甚至不应该在运行react-scripts。构建和开发工作都可以在我的本地计算机上找到。

如果有人有任何建议,我将不胜感激

0 个答案:

没有答案