繁体   English   中英

如何在Ubuntu 13.10上成功安装node.js?

[英]How can I install node.js successfully on Ubuntu 13.10?

我通过apt安装了nodejs,以及nodejs-legacy软件包,试图快速浏览一下这个平台。 不会那么容易。

无论如何,搜索工具不起作用,我认为这意味着安装在某种程度上是不完整的。

谷歌搜索建议它可能与〜/ .npm目录中的权限有关。 我怀疑这一点,但我试图递归地向我的用户chown这个目录以及使用sudo运行命令“npm search”,两者都有相同的结果。

使用额外信息更新:

安装程序:

$sudo apt-get install nodejs nodejs-legacy // the latter makes a symlink

运行命令的输出:

$ npm search
npm ERR! TypeError: Object.keys called on non-object
npm ERR!     at Function.keys (native)
npm ERR!     at stripData (/usr/share/npm/lib/search.js:89:28)
npm ERR!     at Array.map (native)
npm ERR!     at filter (/usr/share/npm/lib/search.js:73:6)
npm ERR!     at /usr/share/npm/lib/search.js:63:21
npm ERR!     at RegClient.requestAll_ (/usr/share/npm/node_modules/npm-registry-  client   /lib/get.js:66:5)
npm ERR!     at RegClient.<anonymous> (/usr/share/npm/node_modules/npm-registry-client /lib/get.js:58:19)
npm ERR!     at fs.js:268:14
npm ERR!     at /usr/lib/nodejs/graceful-fs/graceful-fs.js:103:5
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/x/temp/npm-debug.log npm

npm ERR! System Linux 3.11.6-031106-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "search"
npm ERR! cwd /home/x/
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! type called_on_non_object
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/x/npm-debug.log
npm ERR! not ok code 0

日志文件信息:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'search' ]
2 info using npm@1.2.18
3 info using node@v0.10.15
4 warn Building the local index for the first time, please be patient
5 verbose url raw /-/all
6 verbose url resolving [ 'https://registry.npmjs.org/', './-/all' ]
7 verbose url resolved https://registry.npmjs.org/-/all
8 info trying registry request attempt 1 at 10:56:16
9 http GET https://registry.npmjs.org/-/all
10 http 200 https://registry.npmjs.org/-/all
11 error TypeError: Object.keys called on non-object
11 error     at Function.keys (native)
11 error     at stripData (/usr/share/npm/lib/search.js:89:28)
11 error     at Array.map (native)
11 error     at filter (/usr/share/npm/lib/search.js:73:6)
11 error     at /usr/share/npm/lib/search.js:63:21
11 error     at /usr/share/npm/node_modules/npm-registry-client/lib/get.js:89:14
11 error     at /usr/lib/nodejs/graceful-fs/graceful-fs.js:103:5
11 error     at Object.oncomplete (fs.js:107:15)
12 error If you need help, you may report this log at:
12 error     <http://bugs.debian.org/npm>
12 error or use
12 error     reportbug --attach /home/x/npm-debug.log npm
13 error System Linux 3.11.0-15-generic
14 error command "/usr/bin/nodejs" "/usr/bin/npm" "search"
15 error cwd /home/x
16 error node -v v0.10.15
17 error npm -v 1.2.18
18 error type called_on_non_object
19 verbose exit [ 1, true ]

如何解释和修复此错误? 我无法从这个调试信息中得到任何结果。

虽然“ppa:chris-lea / node.js”做得很好(Moxley Stratton的答案很好),但我不喜欢我的开发环境中的升级周期,不得不依赖第三方PPA,有不同的名字二进制文件(nodejs,node)似乎弄乱了我的脚本。

我从http://nodejs.org/dist/下载节点预编译的tar.gz,并使用不同版本(prod,dev)的自己的文件夹进行维护。 在PATH中为节点和npm维护符号链接。 我的系统(64位)例如

cd node_base_folder
wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-x64.tar.gz
tar -zvxf node-v0.10.24-linux-x64.tar.gz
cd /usr/local/bin
ln -s node_base_folder/node-v0.10.24-linux-x64/bin/node
ln -s node_base_folder/node-v0.10.24-linux-x64/bin/npm

每当您想要移动到新节点版本时。 只需按照上述步骤(更改版本后)

按照“通过软件包管理器安装Node.js”维基页面上的说明,“Ubuntu,Mint,基本操作系统”部分 ,“获取最新版本的节点...”,复制到此处:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

但是,nodejs-legacy也没有为我安装:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  nodejs-legacy
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 15.4 kB of archives.
After this operation, 119 kB of additional disk space will be used.
Get:1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy/universe nodejs-legacy all 0.10.15~dfsg1-4 [15.4 kB]
Fetched 15.4 kB in 0s (243 kB/s)   
Selecting previously unselected package nodejs-legacy.
(Reading database ... 63176 files and directories currently installed.)
Unpacking nodejs-legacy (from .../nodejs-legacy_0.10.15~dfsg1-4_all.deb) ...
dpkg: error processing /var/cache/apt/archives/nodejs-legacy_0.10.15~dfsg1-4_all.deb (--unpack):
 trying to overwrite '/usr/share/man/man1/node.1.gz', which is also in package nodejs 0.10.26-1chl1~saucy1
Processing triggers for man-db ...
Errors were encountered while processing:
 /var/cache/apt/archives/nodejs-legacy_0.10.15~dfsg1-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM