以下是我在heroku网站上手动部署时遇到的错误。首先我在.json文件中收到错误,所以我指定了" npm"," yarn"和"节点"我正在运行的版本。那些错误似乎很明显。现在我就是这个并且已经搜索了谷歌,但似乎无法找到修复它。
----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 9.4.0
engines.npm (package.json): 5.3.0
engines.yarn (package.json): 1.3.2
Resolving node version 9.4.0...
Downloading and installing node 9.4.0...
Bootstrapping npm 5.3.0 (replacing 5.6.0)...
npm 5.3.0 installed
Resolving yarn version 1.3.2...
Downloading and installing yarn (1.3.2)...
Installed yarn 1.3.2
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Installing node modules (yarn.lock)
yarn install v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.1: The platform "linux" is incompatible with this module.
info "fsevents@1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "webpack > ajv-keywords@1.5.1" has unmet peer dependency "ajv@>=4.10.0".
[4/4] Building fresh packages...
$ webpack --config webpack.prod.js
/bin/sh: 1: webpack: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> 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
! Push rejected, failed to compile Node.js app.
! Push failed
这是.json脚本文件:
{
"name": "gun-c4",
"version": "0.0.1",
"description": "Connect four by gunDB",
"main": "server.js",
"scripts": {
"build": "node node_modules/webpack/bin/webpack.js --display-error-details",
"lint": "eslint src/",
"start": "node server.js",
"postinstall": "webpack --config webpack.prod.js",
"build": "webpack",
"build:prod": "webpack --config webpack.prod.js",
"dev": "npm run build -- --watch"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PsychoLlama/connect-four.git"
},
"keywords": [
"connect-four",
"game",
"gun",
"gunDB",
"game",
"real-time"
],
"author": "Jesse Gibson <jesse@gundb.io> (http://techllama.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/PsychoLlama/connect-four/issues"
},
"homepage": "https://github.com/PsychoLlama/connect-four#readme",
"dependencies": {
"connect-four": "0.0.6",
"gun": "^0.3.992",
"random-words": "0.0.1",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-router": "^3.0.0"
},
"devDependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"css-loader": "^0.26.0",
"eslint": "^3.4.0",
"eslint-plugin-react": "^6.2.0",
"node-sass": "^4.0.0",
"sass-loader": "^5.0.0",
"style-loader": "^0.15.0",
"webpack": "^2.2.1"
},
"engines": {
"node": "9.4.0",
"npm": "5.3.0",
"yarn": "1.3.2"
}
}
由于
答案 0 :(得分:2)
试试这个:
heroku config:set NPM_CONFIG_PRODUCTION=false
然后,在你的package.json中,替换&#34; postinstall&#34;你有&#34;脚本&#34;有了这个:
"heroku-postbuild": "webpack --config webpack.prod.js",
有关其他选项,请参阅Hosting a production React app built with Wepback on Heroku。
答案 1 :(得分:0)
如果您运行bpm模块二进制文件,则需要在$PATH
中使用它们。如果脚本在package.json
中定义,则这些二进制文件将自动可访问。否则你需要指明它的位置:
./node_modules/.bin/webpack [args...]