2012-06-03 17 views
6

Ubuntu'ya (12.04) NPM paketleri yüklemeye çalışıyorum. Node.js ve NPM'yi Chris Lea's PPA repository aracılığıyla kurdum.Küresel olarak NPM paketlerini kurarken tutarsız davranış

Uptime project sunucumu sunucuma dağıtmaya çalışıyorum. Sonra bir kök kullanıcı olarak uygulama bağımlılıkları yüklemeye çalışırken, GitHub'dan uygulamayı klonlanmış ettik:

[email protected]:/web/my-application# npm install -g 
npm http GET https://registry.npmjs.org/mongoose/2.5.11 
npm http GET https://registry.npmjs.org/express/2.5.0 
npm http GET https://registry.npmjs.org/ejs/0.6.1 
npm http GET https://registry.npmjs.org/config/0.4.11 
npm http GET https://registry.npmjs.org/async/0.1.18 
npm http GET https://registry.npmjs.org/socket.io/0.9.2 
npm http 304 https://registry.npmjs.org/ejs/0.6.1 
npm http 304 https://registry.npmjs.org/async/0.1.18 
npm http 304 https://registry.npmjs.org/mongoose/2.5.11 
npm http 304 https://registry.npmjs.org/express/2.5.0 
npm http 304 https://registry.npmjs.org/config/0.4.11 
npm http 304 https://registry.npmjs.org/socket.io/0.9.2 
npm http GET https://registry.npmjs.org/mime 
npm http GET https://registry.npmjs.org/connect 
npm http GET https://registry.npmjs.org/mkdirp/0.0.7 
npm http GET https://registry.npmjs.org/qs 
npm http GET https://registry.npmjs.org/policyfile/0.0.4 
npm http GET https://registry.npmjs.org/redis/0.6.7 
npm http GET https://registry.npmjs.org/socket.io-client/0.9.2 
npm http GET https://registry.npmjs.org/yaml 
npm http GET https://registry.npmjs.org/vows 
npm http GET https://registry.npmjs.org/coffee-script 
npm http GET https://registry.npmjs.org/hooks/0.2.0 
npm http GET https://registry.npmjs.org/mongodb/0.9.9-5 
npm http 304 https://registry.npmjs.org/mime 
npm http 304 https://registry.npmjs.org/connect 
npm http 304 https://registry.npmjs.org/mkdirp/0.0.7 
npm http 304 https://registry.npmjs.org/qs 
npm http 304 https://registry.npmjs.org/policyfile/0.0.4 
npm http 304 https://registry.npmjs.org/redis/0.6.7 
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.2 
npm http 304 https://registry.npmjs.org/vows 
npm http 304 https://registry.npmjs.org/yaml 
npm http 304 https://registry.npmjs.org/coffee-script 
npm http 304 https://registry.npmjs.org/hooks/0.2.0 
npm http 304 https://registry.npmjs.org/mongodb/0.9.9-5 
npm http GET https://registry.npmjs.org/eyes 

> [email protected] install /usr/lib/node_modules/node-uptime/node_modules/mongoose/node_modules/mongodb 
> node install.js 

npm http 304 https://registry.npmjs.org/eyes 
================================================================================ 
=                    = 
= To install with C++ bson parser do <npm install mongodb --mongodb:native> = 
=                    = 
================================================================================ 
npm http GET https://registry.npmjs.org/uglify-js/1.2.5 
npm http GET https://registry.npmjs.org/ws 
npm http GET https://registry.npmjs.org/xmlhttprequest/1.2.2 
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1 
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1 
npm http 304 https://registry.npmjs.org/uglify-js/1.2.5 
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.2.2 
npm http 304 https://registry.npmjs.org/ws 
npm http GET https://registry.npmjs.org/zeparser/0.0.5 
npm http GET https://registry.npmjs.org/commander 
npm http GET https://registry.npmjs.org/options 
npm http 304 https://registry.npmjs.org/zeparser/0.0.5 
npm http 304 https://registry.npmjs.org/options 
npm http 304 https://registry.npmjs.org/commander 

> [email protected] install /usr/lib/node_modules/node-uptime/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws 
> node install.js 

================================================================================ 
=                    = 
= To install WS with blazing fast native extensions, use      = 
=  <npm install ws --ws:native>           = 
=                    = 
================================================================================ 
[email protected] /usr/lib/node_modules/node-uptime 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected], [email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected]) 
└── [email protected] ([email protected], [email protected], [email protected]) 

Tüm iyi görünümlü, paketler başarıyla yüklendi gibi görünüyor.

[email protected]:/web/my-application# npm list 
npm WARN mongoose 2.5.11 Unmet dependency in /web/my-application 
npm WARN active-x-obfuscator 0.0.1 Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
npm WARN uglify-js 1.2.5 Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
npm WARN ws 0.4.x Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
npm WARN xmlhttprequest 1.2.2 Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
[email protected] /web/my-application 
├── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
├── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├── UNMET DEPENDENCY mongoose 2.5.11 
└─┬ [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └─┬ [email protected] 
    ├── UNMET DEPENDENCY active-x-obfuscator 0.0.1 
    ├── UNMET DEPENDENCY uglify-js 1.2.5 
    ├── UNMET DEPENDENCY ws 0.4.x 
    └── UNMET DEPENDENCY xmlhttprequest 1.2.2 

olarak bildiğim kadarıyla: Ben NPM paket bağımlılıkları yerine getirilmesi halinde kontrol ediyorum ben bile sadece bir saniye önce bunları yüklemek vermedi gibi Ancak, ben, listelenen karşılanmayan bağımlılıkları bir demet alıyorum (ancak yanılıyorsam düzeltin) NPM, global olarak paketleri kurarken NODE_PATH ortam değişkenine saygı duyar. Yukarıdaki paket yükleme çıktısına bakarsanız, NPM'nin global olarak /usr/lib/node_modules'a bağımlı paketler kurduğunu görebilirsiniz. Ben NODE_PATH ortam değişkeni kontrol çift, bu NODE_PATH değişken farklı ayarlandığını çıkıyor:

[email protected]:/web/my-application# echo $NODE_PATH 
/usr/lib/nodejs:/usr/share/javascript 

bir şey açıklığa kavuşturmak için: Ben NODE_PATH değişken ayarlandı bilmiyorum, bunu belirlemediniz kendim ve Node ve NPM'yi kurduğumda Ubuntu paketiyle geldiğini hissediyorum.

Sonra açıkça NODE_PATH değişken ve kontrol çift bağımlılıkları açmaya karar: Ben düğümle uygulamayı çalıştırmak çalışıyorum ancak ne zaman

[email protected]:/web/my-application# export NODE_PATH=/usr/lib/node_modules 
[email protected]:/web/my-application# npm list 
npm WARN mongoose 2.5.11 Unmet dependency in /web/my-application 
npm WARN active-x-obfuscator 0.0.1 Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
npm WARN uglify-js 1.2.5 Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
npm WARN ws 0.4.x Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
npm WARN xmlhttprequest 1.2.2 Unmet dependency in /web/my-application/node_modules/socket.io/node_modules/socket.io-client 
[email protected] /web/my-application 
├── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
├── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├── UNMET DEPENDENCY mongoose 2.5.11 
└─┬ [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └─┬ [email protected] 
    ├── UNMET DEPENDENCY active-x-obfuscator 0.0.1 
    ├── UNMET DEPENDENCY uglify-js 1.2.5 
    ├── UNMET DEPENDENCY ws 0.4.x 
    └── UNMET DEPENDENCY xmlhttprequest 1.2.2 

Hala başarı, başarıyla başlatır ve çalışır:

[email protected]:/web/my-application# node app.js 
Monitor origin started 
    info - socket.io started 
Express server listening on port 8082 in development mode 
Mongoose: pings.ensureIndex({ timestamp: -1 }) {} 
Mongoose: checkevents.ensureIndex({ timestamp: -1, check: 1 }) {} 
Mongoose: checkhourlystats.ensureIndex({ timestamp: -1, check: 1 }) { unique: true } 
Mongoose: checkdailystats.ensureIndex({ timestamp: -1, check: 1 }) { unique: true } 
Mongoose: checkmonthlystats.ensureIndex({ timestamp: -1, check: 1 }) { unique: true } 
Mongoose: checks.find({ '$where': 'function() {\n if (this.isPaused) return false;\n if (!this.firstTested) return true;\n var delay = (this.lastTested.getTime() - this.firstTested.getTime()) % this.interval;\n return (Date.now() - this.lastTested.getTime() + delay) >= (this.interval || 60000);\n}' }) { fields: { qos: 0 }, safe: true } 
Mongoose: taghourlystats.ensureIndex({ timestamp: -1, name: 1 }) { unique: true } 
Mongoose: tagdailystats.ensureIndex({ timestamp: -1, name: 1 }) { unique: true } 
Mongoose: tagmonthlystats.ensureIndex({ timestamp: -1, name: 1 }) { unique: true } 
Mongoose: tags.ensureIndex({ name: 1 }) { unique: true } 

Şu andan itibaren her şey iyi olacak gibi görünüyor, ancak uygulamayı root olarak çalıştırmayacağım, bu yüzden uygulamayı özel bir uygulama olarak çalıştıracağım zaman tanınan global NPM paketlerine ihtiyacım olacak kullanıcı.

NPM'nin paketleri kurarken bir çeşit tutarsız davranışı olduğunu hissediyorum. Global olarak kurulurken, başarılı bir şekilde çalışır, ancak daha sonra bunları almak için başarısız olur.

Ne yapabilirim ve ayrıca kişinin NODE_PATH ortam değişkeni nasıl görünür?

cevap

5

-g olmadan sadece npm install -d ile kurmanız gerekir. Paketlerin gereksinimleri, her paket için yereldir (a ve node_modules\a\node_modules\b, ab'a bağlı olduğunda node_modules\a'a sahip olmanız gerekir).

Daha fazla ayrıntı için bkz. http://npmjs.org/doc/faq.html#I-installed-something-globally-but-I-can-t-require-it.

+0

çalıştı. Sadece modülün klasörüne git ve oradaki bağımlılığı kur. – Carlton

+0

Üzgünüz, stackoverflow'a geri dönmem biraz zaman aldı. Cevabı onayladı ve kabul etti. teşekkürler pentaur. –

-2

Benim için aşağıdaki komutu kullanarak çözüldü -

npm -d [email protected] yükleyin.önbelleği temizlemeyi 4 --registry http://registry.npmjs.org/

+0

Bu, npm'de bir hata olmalı, kesinlikle varsayılan kayıt defterinden geçerek, dosyaların nasıl kurulduğuna bir etkisi olmamalıdır. Üzgünüm, fakat yukarıdaki cevabın neden işe yaramadığını açıklamıyor diye bu cevaba oy vermeyeceğim. –

2

Ben sorunumu çözmüş olarak bu kabul cevabı olması gerektiğini düşünüyorum benim

npm cache clean