我最近在nodejs
中安装了linux
。并写一个简单的代码:
var http = require('http');
var sleep = require('sleep');
...
我用这个命令安装sleep
:
sudo npm install -g sleep
但是,当我用以下方式运行程序时:
nodejs test.js
我收到这个错误:
Error: Cannot find module 'sleep'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/mlibre/tmp/test/nodejs/test.js:2:13)
...
node -v
v6.6.0
npm -v
3.10.3
npm -g ls | grep sleep
└─┬ sleep@4.0.0