我不知道什麼是造成這個問題,因爲我認爲它應該工作。我都表示安裝,至少根據NPM:節點無法找到快速模塊?
C:\Users\phucker\Desktop>node init.js
module.js:340
throw err;
^
Error: Cannot find module 'express'
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> (C:\Users\phucker\Desktop\init.js:1:77)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
C:\Users\phucker\Desktop>npm express -v
1.3.2
C:\Users\phucker\Desktop>
包含在init.js代碼
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('hello world');
});
app.listen(3000);
爲什麼?如果不能在全球範圍內使用,能夠在全球範圍內安裝某些東西的意義何在? – 2014-08-27 19:38:55
@Sosukodo對此的一個很好的解釋是在[npm博客](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation)全球安裝如果你想使用你的shell中的可執行文件,那就好了。要在程序中將它們用作庫,最好在本地安裝它們。儘管您也可以從全局安裝中創建符號鏈接。 –