【发布时间】:2019-11-04 05:00:34
【问题描述】:
我用 node.js +react 制作了一个应用程序,但我无法在 heroku 上部署它。 它适用于本地主机 我试图删除 package-lock.json 文件,但没有帮助。
这是我在服务器目录中 package.json 中的脚本
"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 install --prefix client && npm run build --prefix client"
还有我的heroku日志
*
-----> 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): 8.1.1 engines.npm (package.json): 5.0.3 Resolving node version 8.1.1... Downloading and installing node 8.1.1... npm 5.0.3 already installed with node -----> Restoring cache - node_modules -----> Installing dependencies Installing node modules (package.json + package-lock) added 93 packages in 7.456s -----> Build Running heroku-postbuild > server@1.0.0 heroku-postbuild /tmp/build_52aeb2bcb298df1839239655d0215864 > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client > fsevents@1.2.9 install /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/jest-haste-map/node_modules/fsevents > node install > fsevents@1.2.9 install /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/chokidar/node_modules/fsevents > node install > core-js-pure@3.1.4 postinstall /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/core-js-pure > node scripts/postinstall || echo "ignore" > core-js@2.6.9 postinstall /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/babel-runtime/node_modules/core-js > node scripts/postinstall || echo "ignore" added 1550 packages in 43.208s > client@0.1.0 build /tmp/build_52aeb2bcb298df1839239655d0215864/client > react-scripts build /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/@hapi/hoek/lib/deep-equal.js:17 options = { prototype: true, ...options }; ^^^ SyntaxError: Unexpected token ... at createScript (vm.js:74:10) at Object.runInThisContext (vm.js:116:10) at Module._compile (module.js:533:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) at require (internal/module.js:11:18) at Object.<anonymous> (/tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/@hapi/hoek/lib/index.js:9:19) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! client@0.1.0 build: `react-scripts build`npm 错误!退出状态 1 npm ERR! npm 错误!在客户端失败@0.1.0 构建脚本。 npm 错误!这可能不是 npm 的问题。那里 可能是上面的附加日志输出。 npm 错误!完整的日志 此运行可在以下位置找到:npm ERR!
/tmp/npmcache.1V3q7/_logs/2019-06-21T10_03_50_779Z-debug.log npm 错误! 代码 ELIFECYCLE npm 错误! errno 1 npm 错误!服务器@1.0.0 heroku-postbuild:NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix clientnpm ERR!退出状态 1 npm 呃! npm 错误!在 server@1.0.0 heroku-postbuild 脚本中失败。 npm 呃!这可能不是 npm 的问题。有可能 上面的附加日志输出。 npm 错误!本次运行的完整日志 可以在以下位置找到:npm ERR!
/tmp/npmcache.1V3q7/_logs/2019-06-21T10_03_50_793Z-debug.log -----> 构建失败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*
【问题讨论】:
-
将您的节点版本至少更新到 8.6.0 以支持对对象文字使用扩展运算符 - 请参阅支持的版本 here
标签: javascript node.js heroku deployment