我想部署一個React項目到Heroku。以前沒有問題,但現在有問題 - 我懷疑這是因爲版本控制?對此還是很新的,所以在這裏可以欣賞一些有用的輸入。Troubleku部署反應項目到heroku
終端錯誤信息:
remote: Installing any new modules (package.json)
remote:
remote: > [email protected] postinstall /tmp/build_66d2f41eb413351a0a39128a0fae4330
remote: > NODE_ENV='production' webpack -p
remote:
remote: sh: 1: webpack: not found
remote: npm ERR! file sh
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno ENOENT
remote: npm ERR! syscall spawn
remote: npm ERR! [email protected] postinstall: `NODE_ENV='production' webpack -p`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the [email protected] postinstall script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2017-06-30T10_39_42_230Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - node_modules checked into source control
remote: https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to d3-barchart-drhectapus.
remote:
To https://git.heroku.com/d3-barchart-drhectapus.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/d3-barchart-drhectapus.git'
的package.json:
{
"name": "react-boilerplate",
"version": "1.0.0",
"description": "Minimal boilerplate for react",
"main": "index.js",
"engines": {
"node": "6.10.2",
"npm": "5.0.4"
},
"scripts": {
"dev": "webpack-dev-server --progress --inline --colors --hot --config ./webpack.config.js",
"postinstall": "NODE_ENV='production' webpack -p",
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"babel": {
"presets": [
"es2015",
"react",
"stage-2"
]
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^0.28.0",
"node-sass": "^4.5.2",
"sass-loader": "^6.0.5",
"style-loader": "^0.16.1",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"axios": "^0.16.2",
"d3": "^4.9.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"redux": "^3.7.1",
"redux-thunk": "^2.2.0"
}
}
我懷疑這是一些與我的節點/ NPM版本?我最近更新節點或npm(不記得哪一個),但之後我似乎有一個問題部署。這是我在終端命令中注意到的:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 6.x via semver.io...
remote: Downloading and installing node 6.11.0...
remote: Detected package-lock.json: defaulting npm to version 5.x.x
remote: Resolving npm version 5.x.x via semver.io...
remote: Downloading and installing npm 5.0.4 (replacing version 3.10.10)...
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new-signature)
你可以嘗試把webpack裏面的依賴關係,而不是開發依賴項 – VivekN
does't仍然工作 – doctopus