我正在尝试在我的应用程序中实现本地模块
1.项目根文件夹我创建了名为 test
的文件夹,文件名为 index.js
module.exports = {
myFunction:function(){
console.log('ok');
}
}
2.在根文件夹中的 package.json
中添加了以下内容
"dependencies": {
"test-module": "file:test"
}
3.当我尝试在 app.js
中导入 var module = require('test-module');
时出现此错误
找不到模块“测试模块”
原文由 shellakkshellu 发布,翻译遵循 CC BY-SA 4.0 许可协议
并执行 npm install -s 或 npm install –save reference