[英]Nodejs cannot find my node module when calling from cmd
当我在全局安装时从命令行调用节点模块时,出现错误提示
could not find /node_modules/insect-tool/cli.js
我在全局节点模块文件夹中签入它。 我该如何解决?
发生这种情况是因为您不维护全局模块结构或pacakge.json
文件在main
属性中存在问题,因此必须放置cli.js
而不是index.js
package.json主要接受模块的入口点
将您的输入javascript文件放在bin
目录中
点击此链接获取更多信息
样本
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"
}
希望它对你有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.