[英]Find the file system location of an installed NodeJS module
我正在看GitHub上grunt-template-jasmine-istanbul項目中的以下代碼;
var DEFAULT_TEMPLATE = __dirname + '/../../../../grunt-contrib-jasmine/tasks/'
+ 'jasmine/templates/DefaultRunner.tmpl';
我之前注意到,您可以(並非一定要)從NodeJS模塊中獲取內部信息,例如:
console.log(require('grunt/package.json'));
但是在這種情況下,該文件是Underscore.js模板,因此您不需要它。
是否可以找到一個npm模塊的安裝位置(可以有所不同),以便對此進行一些強化?
require.resolve(moduleName)
應該為本地安裝的node_modules做花招
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.