我们有一个内部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.
}
});
};我有另一个包B,它在其package.json中列出了包A。目前我们使用npm 2的人很少,想要使用npm 3的人也很少。看起来这些模块不再嵌套在npm 3中,所以使用相对路径对我不起作用。我知道在require语句中,我们可以在路径中给出包名,npm将为我解析它。有没有办法在脚本中自己做同样的事情,这样我就不必担心npm如何安装节点模块了?
发布于 2017-04-24 17:23:13
'get-installed-path‘可以让你找到包的安装路径。
https://stackoverflow.com/questions/38767772
复制相似问题