我想全局安装一个节点模块,以便我可以从任何地方访问它。我跑了下面的命令,显然成功了......
localhost:workspace satishp$ npm install -g git+https://github.com/ryohey/node-stratum-client.git
+ node-stratum-client@0.0.1
updated 1 package in 1.022s
然后我有一个“run.js”文件,其中这是第一行
require("node-stratum-client")
然而,当我去运行我的文件时,它抱怨没有找到我刚刚全局安装的模块。还有什么我需要做的才能让模块全局安装吗?
localhost:workspace satishp$ node run.js
module.js:557
throw err;
^
Error: Cannot find module 'node-stratum-client'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/satishp/Documents/workspace/run.js:1:63)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
答案 0 :(得分:0)
您可以运行npm config get prefix
来查找模块的位置。 I would also recommend checking out this thread for more relevant discussions