我在Heroku上获取应用程序时遇到问题,我收到了以下错误,我已经在Stackoverflow上搜索过了,我看到了回复,说remove/node_modules和package-lock.json,但不幸的是,错误仍然存在。
输出:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> 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): 14.16.1
engines.npm (package.json): unspecified (use default)
Resolving node version 14.16.1...
Downloading and installing node 14.16.1...
Using default npm version: 6.14.12
-----> Installing dependencies
Installing node modules
> nodemon@2.0.15 postinstall /tmp/build_1e107d4a/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 208 packages in 3.879s
-----> Build
Running build
> teste@1.0.0 build /tmp/build_1e107d4a
> concurrently "cd airbnb/ && npm run build"
[0]
[0] > airbnb@0.1.0 build /tmp/build_1e107d4a/airbnb
[0] > react-scripts build
[0]
[0] sh: 1: react-scripts: not found
[0] npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
[0] npm ERR! file sh
npm ERR! errno ENOENT
[0] npm ERR! airbnb@0.1.0 build: `react-scripts build`
[0] npm ERR! spawn ENOENT
[0] npm ERR!
[0] npm ERR! Failed at the airbnb@0.1.0 build script.
[0] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! /tmp/npmcache.ZNegh/_logs/2021-11-16T19_01_58_803Z-debug.log
[0] cd airbnb/ && npm run build exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! teste@1.0.0 build: `concurrently "cd airbnb/ && npm run build"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the teste@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.ZNegh/_logs/2021-11-16T19_01_58_824Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
推送被拒绝,无法编译Node.js应用程序。!推送失败的
好的,问题出在react脚本上,react脚本(默认情况下(是CRA应用程序的devDependency,但Heroku节点构建包具有环境Node_ENV=生产这导致npm安装跳过devDeps。
也要安装这些devDep:
npm install --only=dev && npm install && npm run build
附加信息
请检查您的服务器端(如果您正在使用它(/在根目录中添加不带任何扩展名的Procfile
。
并且在CCD_ 2内部添加CCD_。