1

版本

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!     <npm-@googlegroups.com>

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!     <npm-@googlegroups.com>

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!     <npm-@googlegroups.com>

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  forever@0.10.9 { [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
4

2 回答 2

1

尝试使用nvm安装节点。这会将节点安装在您的主目录中,因此安装全局模块不需要 sudo 权限。看起来您正在安装的模块在相关目录方面存在问题,它可能有助于不使用 sudo。

于 2013-11-21T18:58:37.590 回答
0

用 a 指定的路径.是相对于当前工作目录的,而不是相对于脚本文件的。因此,如果您运行,则可能会找到该文件,node app.js但如果您运行node folder/app.js.

要创建相对于脚本的路径,您必须使用该__dirname变量。

__dirname + '/path/to/file'

于 2013-11-21T18:49:38.313 回答