当前位置:  开发笔记 > 编程语言 > 正文

Heroku Build失败:"node_modules已检入源代码管理"

如何解决《HerokuBuild失败:"node_modules已检入源代码管理"》经验,为你挑选了1个好方法。

我正在Heroku上部署一个基于MEAN堆栈的站点.在解决问题时,我从我的.gitignore文件中删除了node_modules /,因为我的应用程序一直在"构建失败"错误.

我将node_modules /读入文件,但似乎损坏已经完成,因为构建仍然失败.

日志中建议的一个可能的问题是:" - node_modules已检入源代码管理"

如何撤消我所做的事情呢?

 -----> Deleting 1 files matching .slugignore patterns.
 -----> Using set buildpack heroku/nodejs
 -----> Node.js app detected
 -----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NPM_CONFIG_PRODUCTION=true
   NODE_ENV=production
   NODE_MODULES_CACHE=true
 -----> Installing binaries
   engines.node (package.json):  0.10.x
   engines.npm (package.json):   2.x.x

   Resolving node version 0.10.x via semver.io...
   Downloading and installing node 0.10.41...
   Resolving npm version 2.x.x via semver.io...
   Downloading and installing npm 2.14.15 (replacing version 1.4.29)...
   npm WARN deprecated This version of npm lacks support for important features,
   npm WARN deprecated such as scoped packages, offered by the primary npm
   npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
   npm WARN deprecated latest stable version. To upgrade to npm@2, run:
   npm WARN deprecated
   npm WARN deprecated   npm -g install npm@latest-2
   npm WARN deprecated
   npm WARN deprecated To upgrade to the latest stable version, run:
   npm WARN deprecated
   npm WARN deprecated   npm -g install npm@latest
   npm WARN deprecated
   npm WARN deprecated (Depending on how Node.js was installed on your system, you
   npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
   npm WARN deprecated on Windows, run them from an Administrator prompt.)
   npm WARN deprecated
   npm WARN deprecated If you're running the version of npm bundled with
   npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
   npm WARN deprecated will be bundled with a version of npm@2, which has some small
   npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
   npm WARN deprecated semver behavior.
 -----> Restoring cache
   Loading 2 from cacheDirectories (default):
   - node_modules (exists - skipping)
   - bower_components (not cached - skipping)
 -----> Building dependencies
   Prebuild detected (node_modules already exists)
   Rebuilding any native modules

   > bson@0.2.22 install /tmp/build_###########/node_modules/connect-mongo/node_modules/bson
   > (node-gyp rebuild 2> builderror.log) || (exit 0)

   make: Entering directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
   CXX(target) Release/obj.target/bson/ext/bson.o
   SOLINK_MODULE(target) Release/obj.target/bson.node
   COPY Release/bson.node
   make: Leaving directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'

   > bson@0.2.22 install /tmp/build_###########/node_modules/connect-mongo/node_modules/bson
   > (node-gyp rebuild 2> builderror.log) || (exit 0)

   make: Entering directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
   CXX(target) Release/obj.target/bson/ext/bson.o
   SOLINK_MODULE(target) Release/obj.target/bson.node
   COPY Release/bson.node
   make: Leaving directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'

   > bson@0.2.22 install /tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson
   > (node-gyp rebuild 2> builderror.log) || (exit 0)

   make: Entering directory `/tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
   CXX(target) Release/obj.target/bson/ext/bson.o
   SOLINK_MODULE(target) Release/obj.target/bson.node
   COPY Release/bson.node
   make: Leaving directory `/tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'

   > phantomjs@1.9.19 install /tmp/build_###########/node_modules/phantomjs
   > node install.js

   PhantomJS not found on PATH
   Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
   Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
   Receiving...

   Received 12854K total.
   Extracting tar contents (via spawned process)
   Removing /tmp/build_###########/node_modules/phantomjs/lib/phantom
   Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1450118671217/phantomjs-1.9.8-linux-x86_64 -> /tmp/build_###########/node_modules/phantomjs/lib/phantom
   Writing location.js file
   Done. Phantomjs binary available at /tmp/build_###########/node_modules/phantomjs/lib/phantom/bin/phantomjs

   > kerberos@0.0.11 install /tmp/build_###########/node_modules/kerberos
   > (node-gyp rebuild 2> builderror.log) || (exit 0)

   make: Entering directory `/tmp/build_###########/node_modules/kerberos/build'
   CXX(target) Release/obj.target/kerberos/lib/kerberos.o
   CXX(target) Release/obj.target/kerberos/lib/worker.o
   CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
   CC(target) Release/obj.target/kerberos/lib/base64.o
   CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
   SOLINK_MODULE(target) Release/obj.target/kerberos.node
   COPY Release/kerberos.node
   make: Leaving directory `/tmp/build_###########/node_modules/kerberos/build'

   > ws@0.4.32 install /tmp/build_###########/node_modules/ws
   > (node-gyp rebuild 2> builderror.log) || (exit 0)

   make: Entering directory `/tmp/build_###########/node_modules/ws/build'
   CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
   SOLINK_MODULE(target) Release/obj.target/bufferutil.node
   COPY Release/bufferutil.node
   CXX(target) Release/obj.target/validation/src/validation.o
   SOLINK_MODULE(target) Release/obj.target/validation.node
   COPY Release/validation.node
   make: Leaving directory `/tmp/build_###########/node_modules/ws/build'

   > v8-profiler@5.2.12 preinstall /tmp/build_###########/node_modules/v8-profiler
   >


   > v8-profiler@5.2.12 install /tmp/build_###########/node_modules/v8-profiler
   > node-pre-gyp install --fallback-to-build

   sh: 1: node-pre-gyp: Permission denied

   npm ERR! Linux 3.13.0-71-generic
   npm ERR! argv "node" "/tmp/build_###########/.heroku/node/bin/npm" "rebuild"
   npm ERR! node v0.10.41
   npm ERR! npm  v2.14.15
   npm ERR! code ELIFECYCLE
   npm ERR! v8-profiler@5.2.12 install: `node-pre-gyp install --fallback-to-build`
   npm ERR! Exit status 126
   npm ERR!
   npm ERR! Failed at the v8-profiler@5.2.12 install script 'node-pre-gyp install --fallback-to-build'.
   npm ERR! This is most likely a problem with the v8-profiler package,
   npm ERR! not with npm itself.
   npm ERR! Tell the author that this fails on your system:
   npm ERR!     node-pre-gyp install --fallback-to-build
   npm ERR! You can get their info via:
   npm ERR!     npm owner ls v8-profiler
   npm ERR! There is likely additional logging output above.

   npm ERR! Please include the following file with any support request:
   npm ERR!     /tmp/build_###########/npm-debug.log
 -----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   Some possible problems:

   - node_modules checked into source control
   https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git

   Love,
   Heroku

  !     Push rejected, failed to compile Node.js app

Steve.. 11

虽然你已经重新加入node_modules了你.gitignore,但正如你所说,损害已经完成.所以你需要node_modules从你的git repo中删除.试试这个:

git rm -r --cached node_modules
git commit -m 'Remove node_modules'

第一个命令以递归方式node_modules从git repo中删除而不删除本地文件,第二个命令提交删除.

然后,您可以将更改推送到Heroku.



1> Steve..:

虽然你已经重新加入node_modules了你.gitignore,但正如你所说,损害已经完成.所以你需要node_modules从你的git repo中删除.试试这个:

git rm -r --cached node_modules
git commit -m 'Remove node_modules'

第一个命令以递归方式node_modules从git repo中删除而不删除本地文件,第二个命令提交删除.

然后,您可以将更改推送到Heroku.

推荐阅读
和谐啄木鸟
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有