当我在全局安装时从命令行调用我的节点模块时出现错误
could not find /node_modules/insect-tool/cli.js
我检查全局节点模块文件夹,它就在那里。我该如何解决这个问题?
答案 0 :(得分:1)
它的发生是因为你没有维护pacakge.json
属性中的main
文件的全局模块结构或问题,你必须放置cli.js
而不是index.js
package.json主接受模块的入口点
将您的输入javascript文件放在bin
目录
点击此链接获取更多info
示例
package.json
{
"author": "Uzaif nilger",
"license": "BSD",
"name": "test-module",
"version": "0.0.1",
"description": "This is my first module.",
"bin": {
"test-module-exec": "bin/test-module.js"
},
"main" : "cli.js",
"preferGlobal": "true"
}
希望它为你工作