我构建了一个app来练习与nodejs后端的反应。它在localhost上运行正常。但我需要学习如何在Heroku上部署它。我跟随Stephen Grider的Udemy课程并试图在Heroku上主持它。
但我的构建失败了。我多次检查并运行 npm install 。但我无法让它发挥作用。
这是我在服务器
中的 package.json{
"name": "react-movies",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client"
},
"engines": {
"node": "8.9.4",
"npm": "5.7.1"
},
"author": "pankaja92",
"license": "ISC",
"dependencies": {
"concurrently": "^3.5.1",
"moviedb-promise": "^1.2.1",
"express": "^4.16.3",
"nodemon": "^1.17.2"
}
}
这是我得到的构建错误。
Counting objects: 25, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (25/25), 5.50 KiB | 2.75 MiB/s, done.
Total 25 (delta 15), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.9.4
remote: engines.npm (package.json): 5.7.1
remote:
remote: Resolving node version 8.9.4...
remote: Downloading and installing node 8.9.4...
remote: Bootstrapping npm 5.7.1 (replacing 5.6.0)...
remote: npm 5.7.1 installed
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > nodemon@1.17.2 postinstall /tmp/build_ac7e6ff23b1b667ae4e3970742a18cc1/node_modules/nodemon
remote: > node -e "console.log('u001b[32mLove nodemon? You can now support the project via the open collective:u001b[22mu001b[39mn > u001b[96mu001b[1mhttps://opencollective.com/nodemon/donateu001b[0mn')" || exit 0
remote:
remote: Love nodemon? You can now support the project via the open collective:
remote: > https://opencollective.com/nodemon/donate
remote:
remote: added 319 packages from 194 contributors in 7.977s
remote: Running heroku-postbuild
remote:
remote: > react-movies@1.0.0 heroku-postbuild /tmp/build_ac7e6ff23b1b667ae4e3970742a18cc1
remote: > NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client
remote:
remote:
remote: Usage: npm <command>
remote:
remote: where <command> is one of:
remote: access, adduser, bin, bugs, c, cache, ci, completion,
remote: config, ddp, dedupe, deprecate, dist-tag, docs, doctor,
remote: edit, explore, get, help, help-search, i, init, install,
remote: install-test, it, link, list, ln, login, logout, ls,
remote: outdated, owner, pack, ping, prefix, profile, prune,
remote: publish, rb, rebuild, repo, restart, root, run, run-script,
remote: s, se, search, set, shrinkwrap, star, stars, start, stop, t,
remote: team, test, token, tst, un, uninstall, unpublish, unstar,
remote: up, update, v, version, view, whoami
remote:
remote: npm <command> -h quick help on <command>
remote: npm -l display full usage info
remote: npm help <term> search for help on <term>
remote: npm help npm involved overview
remote:
remote: Specify configs in the ini-formatted file:
remote: /app/.npmrc
remote: or on the command line via: npm <command> --key value
remote: Config info can be viewed via: npm help config
remote:
remote: npm@5.7.1 /tmp/build_ac7e6ff23b1b667ae4e3970742a18cc1/.heroku/node/lib/node_modules/npm
remote:
remote: Did you mean one of these?
remote: install
remote: uninstall
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! react-movies@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the react-movies@1.0.0 heroku-postbuild 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! /tmp/npmcache.31Mmf/_logs/2018-03-22T20_32_50_639Z-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: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
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 findthemovie.
remote:
我做错了什么?为什么我的构建失败了?
任何人都可以帮我吗?
答案 0 :(得分:2)
会将此作为评论,但还不能,请检查配置文件
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client"
中的拼写错误
那不应该是安装吗?
答案 1 :(得分:1)
npm install
> NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client
应该是
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
答案 2 :(得分:1)
我相信您的代码中有错别字。
它应该是安装而不是全部:
NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
答案 3 :(得分:0)
将此代码添加到server.js文件中
NULL