[英]can I load dependencies in a separate folder other than node_modules via package.json
When I run this I am downloading all the dependencies in the node_modules directory 运行此命令时,我正在下载node_modules目录中的所有依赖项
{
"name": "bootstrap-test-app",
"engine": "node 5.5.0",
"engineStrict": false,
"version": "1.0.0",
"description": "",
"main": "master.js",
"scripts": {},
"author": "soum",
"license": "BSD-2-Clause",
"devDependencies": {},
"dependencies": {
"bootstrap-sass": "latest",
"jquery": "3.1.1",
"requirejs": "2.1.22"
}
}
My question is it possible to set a path for the dependencies instead of node_modules for example lets say in a dorectory called "dependencies"? 我的问题是可以为依赖项设置路径,而不是为node_modules设置路径吗?例如,让我们在称为“依赖项”的目录中说吗? Can I set a destination property relative to the root of project so that my file structure looks like this
我可以相对于项目的根设置目标属性,以便我的文件结构如下所示吗
my-app
package.json
dependencies
-bootstrap-sass
-jquery
-requirejs
node_modules
No, it is not possible now and it is very unlikely to be possible in the future. 不,现在不可能了,将来也不太可能。
See this issue on GitHub from 2013 and the comments there: 从2013年开始在GitHub上查看此问题,并在此处发表评论:
The future of that can be summarize by two quotes from that discussion: 该讨论的未来可以通过该讨论中的两句话来总结:
See also an older issue from 2011: 另请参阅2011年以来的旧问题:
What you can do is to create a directory that you want and a symlink called node_modules
with something like that: 您可以做的是创建一个所需的目录以及一个名为
node_modules
的符号链接,其内容如下:
$ mkdir dependencies
$ ln -sv dependencies node_modules
‘node_modules’ -> ‘dependencies’
$ npm i tryjson -S
customdeps@1.0.0 /home/rsp/node/test/customdeps
└── tryjson@1.1.4
$ ls dependencies
tryjson
I just came up with that idea. 我只是想出了这个主意。 I wasn't sure if npm can install in a symlinked directory but I just tested it and it turns out that it can.
我不确定npm是否可以安装在符号链接目录中,但我刚刚对其进行了测试,事实证明它可以。
Of course to actually use those dependencies in Node, you'd have to set the NODE_PATH
environment variable accordingly. 当然,要在Node中实际使用这些依赖项,您必须相应地设置
NODE_PATH
环境变量。 See: 看到:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.