[英]npm install - preserve existing files in node_modules
I have taken over a NodeJS project where, for convenience, some symlinks have been placed in the node_modules
directory, which has been version controlled (just with the symlinks, not with any packages). 我已经接管了一个NodeJS项目,为方便起见,已将一些符号链接放置在受版本控制的node_modules
目录中(仅使用符号链接,而不使用任何软件包)。
Upon running npm install
to install the packages, the entire directory is replaced and those files are deleted, causing the script that runs after the install to fail as it depends on those files existing. 运行npm install
安装软件包时,将替换整个目录并删除这些文件,从而导致安装后运行的脚本失败,因为该脚本取决于现有的文件。
"dependencies": {},
"scripts": {
"prepublish": "deployment/prepublish"
},
"devDependencies": {
"browserify": "^9.0.8",
"bulk-require": "^0.2.1",
"bulkify": "^1.1.1",
"deasync": "^0.1.4",
"del": "^1.1.1",
"gulp": "^3.8.11",
"gulp-angular-gettext": "^2.1.0",
"gulp-compass": "^2.0.4",
"gulp-concat": "^2.5.2",
"gulp-merge": "^0.1.0",
"gulp-replace": "^0.5.3",
"gulp-rev-all": "^0.8.18",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4",
"gulp-watch": "^4.2.4",
"jshint": "*",
"lodash": "*",
"merge-stream": "^0.1.7",
"q": "*",
"request": "*",
"run-sequence": "^1.0.2",
"stringify": "^3.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"vinyl-transform": "^1.0.0"
}
How do I ensure that these files are preserved upon npm install
? 我如何确保在npm install
保留这些文件? I know for a fact this used to work in earlier versions of npm but I haven't seen anything in the changelogs. 我知道这曾经在npm的早期版本中起作用,但我在变更日志中什么都没看到。
Thanks in advance for the help! 先谢谢您的帮助!
When npm install
is run, it will examine the package.json
file and attempt to install any dependencies listed that are not already installed to the node_modules
directory. npm install
,它将检查package.json
文件并尝试安装列出的所有尚未安装到node_modules
目录的node_modules
。 If there are no dependencies listed, it replaces the entire node_modules
directory. 如果没有列出依赖项,它将替换整个node_modules
目录。
To preserve the files in the node_modules
directory, you can do the following: 要将文件保留在node_modules
目录中,可以执行以下操作:
dependencies
list in the package.json
. 安装一个模块,并将其添加到package.json
的dependencies
列表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.