[英]Get node_modules directory
We have an internal npm package lets call it A. I have a script in there which references some files in it's node_modules directory as such 我们有一个内部npm包,可以将其称为A。我在那里有一个脚本,该脚本引用了它的node_modules目录中的一些文件,例如
var path = require('path');
/**
* Contains tasks for webdriver
*/
module.exports = function(grunt) {
var test_protractor_bin = path.resolve(__dirname + '/../node_modules/protractor/bin');
grunt.config.merge({
exec: {
webdriverUpdate: {
command: test_protractor_bin + '/webdriver-manager update'
},
// test runs that crash can leave zombie chromedriver processes. call this to kill them.
}
});
};
I have another package B which lists package A in its package.json. 我还有另一个包B,它在package.json中列出了包A。 Currently we have few folks who use npm 2 and we are having few folks who want to use npm 3. It looks like the modules are installed no longer nested in npm 3 so using relative paths doesn't work for me. 当前,很少有人使用npm 2,而很少有人想要使用npm3。看起来模块安装不再嵌套在npm 3中,因此使用相对路径对我不起作用。 I know in the require statement we can give the package name in the path and npm will resolve it for it me. 我知道在require语句中,我们可以在路径中给出软件包名称,而npm会为我解决它。 Is there a way to do the same thing in the script it self so that I don't have to worry about how npm install's the node modules? 有没有办法在脚本本身中做同样的事情,这样我就不必担心npm install的节点模块如何了?
“ get-installed-path ”使您可以找到软件包的安装路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.