[英]Nodejs cannot find my node module when calling from cmd
When I call my node module from the command line when it is installed globally I get an error saying it 当我在全局安装时从命令行调用节点模块时,出现错误提示
could not find /node_modules/insect-tool/cli.js
I check in the global node modules folder and it is there. 我在全局节点模块文件夹中签入它。 How do I fix this?
我该如何解决?
Its happen because of you doesn't maintain the global module structure or problem with your pacakge.json
file in main
property you have to put cli.js
instead of index.js 发生这种情况是因为您不维护全局模块结构或
pacakge.json
文件在main
属性中存在问题,因此必须放置cli.js
而不是index.js
package.json main accept entry point of your module package.json主要接受模块的入口点
Place your entry javascript file in bin
directory 将您的输入javascript文件放在
bin
目录中
follow this link for more info 点击此链接获取更多信息
Sample
package.json
样本
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"
}
hope its work for you 希望它对你有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.