[英]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.