【问题标题】:Node_modules path corrupt, impossible to commit on GITNode_modules 路径损坏,无法在 GIT 上提交
【发布时间】:2014-05-27 09:30:10
【问题描述】:

我正在尝试在 node_modules 中保留所有组件的 git 版本。 我刚刚从 .gitignore 中删除了 node_modules 文件夹,我希望在得到它之前可以顺利同步:

The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/download/node_modules/decompress/node_modules/adm-zip/package.json.
The file will have its original line endings in your working directory.
fatal: unable to stat 'node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/download/node_modules/decompress/node_modules/adm-zip/test/assets/attributes_test/New folder/hidden.txt': No such file or directory

Git 在此文件上崩溃,无法找到。

当我使用资源管理器时,路径上有错误:

 node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/gifsicle/node_modules/bin-wrapper

 node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/gifsicle/node_modules.bin-wrapper

有没有正确的方法在不破坏依赖关系的情况下推入 git ?

【问题讨论】:

  • 为什么要使用angularjs标签?
  • 对了,刚去掉,你知道npm吗?也许你不能提供更多帮助
  • 不,我不知道。出现这种情况时我正在浏览 angularjs 标签,不幸的是我不知道如何提供帮助。
  • 正确的方法是根本不将node_modules文件夹包含在git存储库中。 NPM 在执行npm install 命令后通过查看package.json 文件来安装所需的模块。
  • 如果 NPM 出现故障,并且有一天 apt-get 从存储库中删除了 tomcat 5,我的所有项目都会崩溃吗?

标签: node.js git npm yeoman


【解决方案1】:

如您所见,该文件是adm-zip 包测试套件的固定装置。从它的名字 (attributes_test/New folder/hidden.txt) 你可以看出这个文件有些特殊并且可能表现出奇怪的行为(我认为这个行为的某些部分已经过测试)。由于 git 无法处理这样的文件,因此您可以做的最好的事情是将其显式添加到 .gitignore。对于其他文件或包,您不太可能会遇到此类问题。

顺便说一句,将node_modules 包含到存储库中是已部署应用程序(即非库)的标准做法。比如https://github.com/npm/npm-www

【讨论】:

    猜你喜欢
    • 2014-12-21
    • 2021-06-12
    • 2014-10-22
    • 1970-01-01
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-22
    相关资源
    最近更新 更多