gpt4 book ai didi

node.js - 由于 Windows 上的长路径错误,无法将 Node js 模块添加到 git

转载 作者:太空宇宙 更新时间:2023-11-04 00:47:30 24 4
gpt4 key购买 nike

我将 email-template node.js 模块添加到我的项目中。它已经自动添加了依赖项。由于 Windows 上的长路径错误,其中一组无法添加到 git。

其中一个文件:

D:/t/nodeTest/node_modules/email-templates/node_modules/juice/node_modules/web-resource-inliner/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/.travis.yml

我注意到有很多依赖关系。

我还尝试使用npm dedupe来创建平坦路径。但它也对这些文件发出了不可避免的冲突警告。

有什么方法可以将这些文件添加到git中吗?或者缩短文件路径?或者使依赖关系变得平坦?

最佳答案

您通常不希望包含源代码控制系统依赖项的源文件,因为它们不是您项目的一部分。

您应该将 node_modules 文件夹添加到 gitignore 文件中,并确保将所有依赖项添加到 package.json (例如,通过 npm install --save)

每当你(或任何其他人)想要运行项目时,比如在克隆/ fork 它或简单地 pull 最新提交之后,你只需 npm install 来下载所有必需的依赖项(即让 npm 处理外部依赖项,而不是 git)。

让我再次强调,不要跟踪文件的外部依赖项,这绝对不是正确的方法。

关于node.js - 由于 Windows 上的长路径错误,无法将 Node js 模块添加到 git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33981090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com