我写了一个模块,我刚才将其发布到npm(https://npmjs.org/package/wisp)
因此,可以从命令行进行安装:
$ npm i -g wisp
但是,当我从命令行运行它时,我不断收到未安装乐观主义者的错误消息:
$ wisp
Error: Cannot find module 'optimist'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:12:10)
at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:96:4)
at Module._compile (module.js:449:26)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25)
at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29)
at fs.stat.notSources.(anonymous function) (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18)
但是,我在package.json中指定了依赖性:
{
"name": "wisp",
"author": "Brendan Scarvell <bscarvell@gmail.com>",
"version": "0.1.0",
"description": "Global nodejs file server",
"dependencies": {
"optimist": "~0.3.4"
},
"repository": "git://github.com/tehlulz/wisp",
"bin": {
"wisp" : "./wisp"
}
}
有谁知道该怎么做才能运行?我知道它与bin部分有关,将可执行文件添加到bin中,该目录中的node_modules为空。不知道该如何解决。
./node_modules/wisp/wisp
很好。