![](/img/trans.png)
[英]npm ERR! missing script: build when deploying react app to heroku
[英]Deploying React/Flask app on Heroku: npm ERR! code ENOENT
我有一個帶有反應前端和 python flask 后端的應用程序。 我正在嘗試將我的項目部署到 heroku。 我已按照本教程進行操作。 但是當我嘗試將我的項目推送到 master 時,我不斷收到此錯誤:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.2...
Using default npm version: 6.14.5
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /tmp/build_0912bba7c20dc3b2b0f5ffd13fe70109/node_modules/semver/bin/semver.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/build_0912bba7c20dc3b2b0f5ffd13fe70109/node_modules/semver/bin/semver.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.WnwYf/_logs/2020-07-14T16_30_34_532Z-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
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
我已經嘗試了這 2 個建議,但它並沒有改變任何東西。
僅供參考, .gitignore
看起來像這樣:
# dependencies
/node_modules
/.pnp
.pnp.js
env
# testing
/coverage
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
__pycache__
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
和package.json
看起來像這樣:
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.10.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"material-design-icons": "^3.0.1",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-stopwatch": "^2.0.4",
"symbols": "0.0.6"
},
"scripts": {
"start": "react-scripts start",
"start-api": "cd api && python app.py",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000",
"engines": {
"node": "14.x",
"npm": "6.x"
}
}
感謝您的任何幫助!
我有一個帶有反應前端和 python flask 后端的應用程序。 我正在嘗試將我的項目部署到 heroku。 我已按照本教程進行操作。 但是當我嘗試將我的項目推送到 master 時,我不斷收到此錯誤:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.2...
Using default npm version: 6.14.5
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /tmp/build_0912bba7c20dc3b2b0f5ffd13fe70109/node_modules/semver/bin/semver.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/build_0912bba7c20dc3b2b0f5ffd13fe70109/node_modules/semver/bin/semver.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.WnwYf/_logs/2020-07-14T16_30_34_532Z-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
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
我已經嘗試了這 2 個建議,但它並沒有改變任何東西。
僅供參考, .gitignore
看起來像這樣:
# dependencies
/node_modules
/.pnp
.pnp.js
env
# testing
/coverage
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
__pycache__
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
和package.json
看起來像這樣:
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.10.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"material-design-icons": "^3.0.1",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-stopwatch": "^2.0.4",
"symbols": "0.0.6"
},
"scripts": {
"start": "react-scripts start",
"start-api": "cd api && python app.py",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000",
"engines": {
"node": "14.x",
"npm": "6.x"
}
}
感謝您的任何幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.