2013-11-21 98 views
1

版本問題上樹莓派安裝的node.js/NPM永遠

Linux distro and version: Raspbian GNU/Linux 7 (wheezy)" 
Python: 2.7.3 
Nodejs: v0.10.22 
NPM: 1.3.15 

每次我試圖在它沒有我的樹莓派永遠全球安裝。錯誤列在下面。

sudo npm install forever -g 
npm http GET https://registry.npmjs.org/forever 
npm http 304 https://registry.npmjs.org/forever 
npm http GET https://registry.npmjs.org/utile/0.1.7 
npm http GET https://registry.npmjs.org/winston/0.7.1 
npm http GET https://registry.npmjs.org/colors/0.6.0-1 
npm http GET https://registry.npmjs.org/cliff/0.1.8 
npm http GET https://registry.npmjs.org/flatiron/0.3.5 
npm http GET https://registry.npmjs.org/forever-monitor/1.2.3 
npm http GET https://registry.npmjs.org/nconf/0.6.7 
npm http GET https://registry.npmjs.org/nssocket 
npm http GET https://registry.npmjs.org/optimist/0.4.0 
npm http GET https://registry.npmjs.org/pkginfo/0.3.0 
npm http GET https://registry.npmjs.org/timespan/2.0.1 
npm http GET https://registry.npmjs.org/watch/0.7.0 
npm http 304 https://registry.npmjs.org/utile/0.1.7 
npm http 304 https://registry.npmjs.org/cliff/0.1.8 
npm http 304 https://registry.npmjs.org/winston/0.7.1 
npm http 304 https://registry.npmjs.org/colors/0.6.0-1 
npm http 304 https://registry.npmjs.org/forever-monitor/1.2.3 
npm http 304 https://registry.npmjs.org/nconf/0.6.7 
npm http 304 https://registry.npmjs.org/nssocket 
npm http 304 https://registry.npmjs.org/optimist/0.4.0 
npm http 304 https://registry.npmjs.org/flatiron/0.3.5 
npm http 304 https://registry.npmjs.org/pkginfo/0.3.0 
npm http 304 https://registry.npmjs.org/timespan/2.0.1 
npm http 304 https://registry.npmjs.org/watch/0.7.0 
npm http GET https://registry.npmjs.org/eventemitter2 
npm http GET https://registry.npmjs.org/lazy 
npm http GET https://registry.npmjs.org/async 
npm http GET https://registry.npmjs.org/deep-equal 
npm http GET https://registry.npmjs.org/i 
npm http GET https://registry.npmjs.org/mkdirp 
npm http GET https://registry.npmjs.org/ncp 
npm http GET https://registry.npmjs.org/rimraf 
npm http 304 https://registry.npmjs.org/lazy 
npm http 304 https://registry.npmjs.org/eventemitter2 
npm http 304 https://registry.npmjs.org/mkdirp 
npm http 304 https://registry.npmjs.org/ncp 
npm http 304 https://registry.npmjs.org/rimraf 
npm http 304 https://registry.npmjs.org/async 
npm http 304 https://registry.npmjs.org/deep-equal 
npm http 304 https://registry.npmjs.org/i 
npm http GET https://registry.npmjs.org/wordwrap 
npm http 304 https://registry.npmjs.org/wordwrap 
npm http GET https://registry.npmjs.org/broadway 
npm http GET https://registry.npmjs.org/minimatch 
npm http GET https://registry.npmjs.org/ps-tree 
npm http GET https://registry.npmjs.org/watch 
npm http GET https://registry.npmjs.org/broadway/0.2.7 
npm http GET https://registry.npmjs.org/optimist/0.3.5 
npm http GET https://registry.npmjs.org/prompt/0.2.9 
npm http GET https://registry.npmjs.org/director/1.1.10 
npm http 304 https://registry.npmjs.org/minimatch 
npm http 304 https://registry.npmjs.org/broadway 
npm http 304 https://registry.npmjs.org/watch 
npm http 304 https://registry.npmjs.org/broadway/0.2.7 
npm http 304 https://registry.npmjs.org/optimist/0.3.5 
npm http 304 https://registry.npmjs.org/prompt/0.2.9 
npm http 304 https://registry.npmjs.org/director/1.1.10 
npm http 304 https://registry.npmjs.org/ps-tree 
npm ERR! Error: ENOENT, open '/usr/local/lib/node_modules/forever/node_modules/cliff/examples/put-rows-colors.js' 
npm ERR! If you need help, you may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 

npm ERR! System Linux 3.6.11+ 
npm ERR! command "node" "/usr/local/bin/npm" "install" "forever" "-g" 
npm ERR! cwd /home/pi 
npm ERR! node -v v0.10.22 
npm ERR! npm -v 1.3.15 
npm ERR! path /usr/local/lib/node_modules/forever/node_modules/cliff/examples/put-rows-colors.js 
npm ERR! code ENOENT 
npm ERR! errno 34 
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/forever/node_modules/winston/test/log-rewriter-test.js' 
npm ERR! If you need help, you may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 

npm ERR! System Linux 3.6.11+ 
npm ERR! command "node" "/usr/local/bin/npm" "install" "forever" "-g" 
npm ERR! cwd /home/pi 
npm ERR! node -v v0.10.22 
npm ERR! npm -v 1.3.15 
npm ERR! path /usr/local/lib/node_modules/forever/node_modules/winston/test/log-rewriter-test.js 
npm ERR! fstream_path /usr/local/lib/node_modules/forever/node_modules/winston/test/log-rewriter-test.js 
npm ERR! fstream_type File 
npm ERR! fstream_class FileWriter 
npm ERR! code ENOENT 
npm ERR! errno 34 
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26 
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) 
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/test/lines.js' 
npm ERR! If you need help, you may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 

npm ERR! System Linux 3.6.11+ 
npm ERR! command "node" "/usr/local/bin/npm" "install" "forever" "-g" 
npm ERR! cwd /home/pi 
npm ERR! node -v v0.10.22 
npm ERR! npm -v 1.3.15 
npm ERR! path /usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/test/lines.js 
npm ERR! fstream_path /usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/test/lines.js 
npm ERR! fstream_type File 
npm ERR! fstream_class FileWriter 
npm ERR! code ENOENT 
npm ERR! errno 34 
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26 
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) 
npm ERR! EEXIST, mkdir '/usr/local/lib/node_modules/forever/node_modules/nconf/lib/nconf/stores' 
File exists: /usr/local/lib/node_modules/forever/node_modules/nconf/lib/nconf/stores 
Move it away, and try again. 

npm ERR! System Linux 3.6.11+ 
npm ERR! command "node" "/usr/local/bin/npm" "install" "forever" "-g" 
npm ERR! cwd /home/pi 
npm ERR! node -v v0.10.22 
npm ERR! npm -v 1.3.15 
npm ERR! path /usr/local/lib/node_modules/forever/node_modules/nconf/lib/nconf/stores 
npm ERR! fstream_path /usr/local/lib/node_modules/forever/node_modules/nconf/lib/nconf/stores/file.js 
npm ERR! fstream_type File 
npm ERR! fstream_class FileWriter 
npm ERR! code EEXIST 
npm ERR! errno 47 
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23 
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53 
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) 
npm ERR! Failed to parse json 
npm ERR! Unexpected end of input 
npm ERR! File: /root/.npm/broadway/0.2.7/package/package.json 
npm ERR! Failed to parse package.json data. 
npm ERR! package.json must be actual JSON, not just JavaScript. 
npm ERR! 
npm ERR! This is not a bug in npm. 
npm ERR! Tell the package author to fix their package.json file. JSON.parse 

npm ERR! System Linux 3.6.11+ 
npm ERR! command "node" "/usr/local/bin/npm" "install" "forever" "-g" 
npm ERR! cwd /home/pi 
npm ERR! node -v v0.10.22 
npm ERR! npm -v 1.3.15 
npm ERR! file /root/.npm/broadway/0.2.7/package/package.json 
npm ERR! code EJSONPARSE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/pi/npm-debug.log 
npm ERR! not ok code 0 

同樣的,如果我嘗試這樣做沒有sudo,我得到如下:

.指定
npm install forever -g 
npm http GET https://registry.npmjs.org/forever 
npm http 304 https://registry.npmjs.org/forever 
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/forever' 
npm ERR! error rolling back [email protected] { [Error: EACCES, unlink '/usr/local/lib/node_modules/forever'] 
npm ERR! error rolling back errno: 3, 
npm ERR! error rolling back code: 'EACCES', 
npm ERR! error rolling back path: '/usr/local/lib/node_modules/forever' } 
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/forever' 
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/forever'] 
npm ERR! errno: 3, 
npm ERR! code: 'EACCES', 
npm ERR! path: '/usr/local/lib/node_modules/forever' } 
npm ERR! 
npm ERR! Please try running this command again as root/Administrator. 

npm ERR! System Linux 3.6.11+ 
npm ERR! command "node" "/usr/local/bin/npm" "install" "forever" "-g" 
npm ERR! cwd /home/pi 
npm ERR! node -v v0.10.22 
npm ERR! npm -v 1.3.15 
npm ERR! path /usr/local/lib/node_modules/forever 
npm ERR! code EACCES 
npm ERR! errno 3 
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/forever' 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/pi/npm-debug.log 
npm ERR! not ok code 0 

回答

0

路徑是相對於當前的工作目錄,而不是相對於腳本文件。因此,如果您運行node app.js,則可以找到該文件,但如果運行node folder/app.js,則可能找不到該文件。

要相對腳本路徑,則必須使用__dirname變量。

__dirname + '/path/to/file' 

Src

1

嘗試用nvm安裝節點。這會在主目錄中安裝節點,因此安裝全局模塊時不需要sudo權限。 它看起來像你正在安裝的模塊有相關目錄的問題,它可以幫助不使用sudo。

+0

這會解決全局安裝問題嗎?我需要運行一個命令,比如'forever blah' – gazzwi86

+0

是的,那會的。我可以在我的用戶下運行所有​​全局模塊,沒有任何問題! – sheldonk