在将节点服务器更新到版本6.11.1以响应来自Heroku的最新安全更新电子邮件之后,我无法再推送我的本地主服务器更改。更新后服务器和应用程序重新启动。
我已尝试删除并重新安装所有node_modules,提交更改并且应用程序在本地运行时没有错误,但在尝试部署主服务器时遇到相同的构建失败。我对package.json文件所做的唯一更改是添加之前未指定的npm版本。
安装节点模块时,日志中的服务器构建失败:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: npm ERR! Cannot read property '0' of undefined
力量推动最好/一个好的解决方案吗?
这是完整的日志:
Counting objects: 18, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 8.80 KiB | 0 bytes/s, done.
Total 18 (delta 13), 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: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 6.11.1
remote: engines.npm (package.json): 5.3.0
remote:
remote: Downloading and installing node 6.11.1...
remote: Downloading and installing npm 5.3.0 (replacing version 3.10.10)...
remote:
remote: -----> Restoring cache
remote: Loading 2 from cacheDirectories (default):
remote: - node_modules
remote: - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: npm ERR! Cannot read property '0' of undefined
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2017-07-20T22_54_19_003Z-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 app-name.
remote:
To https://git.heroku.com/app-name.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/app-name.git'
感谢。
答案 0 :(得分:1)
更新到节点6.11.1和npm 5.3.0后,我收到了相同的错误消息。 heroku支持建议我运行这些命令:
heroku plugins:install heroku-repo
heroku repo:purge_cache -a APPNAME
git commit --allow-empty -m "Purge cache"
git push heroku master
...其中" APPNAME"是我的应用程序的heroku标识符。
解决了错误,我没有必要恢复到早期版本的npm。我已经要求提供解释,但他们还没有回复(几分钟前刚问过)。
更新2017-07-27: heroku支持回复并说,"我们仍在努力解决这个问题,但这似乎是相当间歇性的。&# 34;现在我已经安装了插件(见上文),我正在运行这些步骤来更新我的应用程序:
heroku repo:purge_cache -a APPNAME
git push heroku master
这对我来说是可靠的。