2015-09-21 121 views
0

我想安裝摩卡測試框架,但爲此我們需要NPM所以我跑以下命令

2. npm install -g mocha如何在ubuntu上安裝npm?

但要當我跑第一個命令下面的錯誤

[email protected]:~/mochatest$ sudo apt-get install npm 
[sudo] password for user: 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
The following packages were automatically installed and are no longer required: 
    apt-clone archdetect-deb autogen ax25-node binutils-mingw-w64-i686 
    binutils-mingw-w64-x86-64 dmraid g++-mingw-w64 g++-mingw-w64-i686 
    g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-base gcc-mingw-w64-i686 
    gcc-mingw-w64-x86-64 gfortran-mingw-w64 gfortran-mingw-w64-i686 
    gfortran-mingw-w64-x86-64 gir1.2-json-1.0 gir1.2-timezonemap-1.0 
    gir1.2-xkl-1.0 gnat-mingw-w64 gnat-mingw-w64-base gnat-mingw-w64-i686 
    gnat-mingw-w64-x86-64 kpartx kpartx-boot libax25 libdebian-installer4 
    libdevmapper-event1.02.1 libdmraid1.0.0.rc16 libopts25 libopts25-dev lvm2 
    mingw-w64 mingw-w64-common mingw-w64-i686-dev mingw-w64-x86-64-dev 
    openbsd-inetd python3-icu python3-pam quilt rdate watershed 
Use 'apt-get autoremove' to remove them. 
The following extra packages will be installed: 
    node-abbrev node-ansi node-archy node-async node-block-stream 
    node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent 
    node-form-data node-fstream node-fstream-ignore node-github-url-from-git 
    node-glob node-graceful-fs node-gyp node-inherits node-ini 
    node-json-stringify-safe node-lockfile node-lru-cache node-mime 
    node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt 
    node-normalize-package-data node-npmlog node-once node-osenv node-qs 
    node-read node-read-package-json node-request node-retry node-rimraf 
    node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent 
    node-which nodejs-dev 
Suggested packages: 
    node-hawk node-aws-sign node-oauth-sign node-http-signature 
The following NEW packages will be installed: 
    node-abbrev node-ansi node-archy node-async node-block-stream 
    node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent 
    node-form-data node-fstream node-fstream-ignore node-github-url-from-git 
    node-glob node-graceful-fs node-gyp node-inherits node-ini 
    node-json-stringify-safe node-lockfile node-lru-cache node-mime 
    node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt 
    node-normalize-package-data node-npmlog node-once node-osenv node-qs 
    node-read node-read-package-json node-request node-retry node-rimraf 
    node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent 
    node-which nodejs-dev npm 
0 upgraded, 46 newly installed, 0 to remove and 656 not upgraded. 
Need to get 0 B/945 kB of archives. 
After this operation, 4,780 kB of additional disk space will be used. 
Do you want to continue? [Y/n] y 
E: Invalid archive signature 
E: Internal error, could not locate member control.tar.{gzbz2xzlzma} 
E: Prior errors apply to /var/cache/apt/archives/node-fstream_0.1.24-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-lru-cache_2.3.1-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-sigmund_1.0.0-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-minimatch_0.2.12-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-fstream-ignore_0.0.6-2_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-github-url-from-git_1.1.1-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-glob_3.2.6-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/nodejs-dev_0.10.25~dfsg2-2ubuntu1_amd64.deb 
E: Prior errors apply to /var/cache/apt/archives/node-nopt_2.1.2-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-npmlog_0.0.4-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-osenv_0.0.3-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-tunnel-agent_0.3.1-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-json-stringify-safe_5.0.0-1_all.deb 
E: Prior errors apply to /var/cache/apt/archives/node-qs_0.6.5-1_all.deb 
debconf: apt-extracttemplates failed: No such file or directory 
Extracting templates from packages: 100% 
Selecting previously unselected package node-async. 
(Reading database ... 194080 files and directories currently installed.) 
Preparing to unpack .../node-async_0.2.5-1_all.deb ... 
Unpacking node-async (0.2.5-1) ... 
Selecting previously unselected package node-node-uuid. 
Preparing to unpack .../node-node-uuid_1.4.0-1_all.deb ... 
Unpacking node-node-uuid (1.4.0-1) ... 
Selecting previously unselected package node-abbrev. 
Preparing to unpack .../node-abbrev_1.0.4-2_all.deb ... 
Unpacking node-abbrev (1.0.4-2) ... 
Selecting previously unselected package node-ansi. 
Preparing to unpack .../node-ansi_0.2.1-1_all.deb ... 
Unpacking node-ansi (0.2.1-1) ... 
Selecting previously unselected package node-archy. 
Preparing to unpack .../node-archy_0.0.2-1_all.deb ... 
Unpacking node-archy (0.0.2-1) ... 
Selecting previously unselected package node-inherits. 
Preparing to unpack .../node-inherits_2.0.0-1_all.deb ... 
Unpacking node-inherits (2.0.0-1) ... 
Selecting previously unselected package node-block-stream. 
Preparing to unpack .../node-block-stream_0.0.7-1_all.deb ... 
Unpacking node-block-stream (0.0.7-1) ... 
Selecting previously unselected package node-delayed-stream. 
Preparing to unpack .../node-delayed-stream_0.0.5-1_all.deb ... 
Unpacking node-delayed-stream (0.0.5-1) ... 
Selecting previously unselected package node-combined-stream. 
Preparing to unpack .../node-combined-stream_0.0.4-1_all.deb ... 
Unpacking node-combined-stream (0.0.4-1) ... 
Selecting previously unselected package node-cookie-jar. 
Preparing to unpack .../node-cookie-jar_0.3.1-1_all.deb ... 
Unpacking node-cookie-jar (0.3.1-1) ... 
Selecting previously unselected package node-forever-agent. 
Preparing to unpack .../node-forever-agent_0.5.1-1_all.deb ... 
Unpacking node-forever-agent (0.5.1-1) ... 
Selecting previously unselected package node-mime. 
Preparing to unpack .../node-mime_1.2.11-1_all.deb ... 
Unpacking node-mime (1.2.11-1) ... 
Selecting previously unselected package node-form-data. 
Preparing to unpack .../node-form-data_0.1.0-1_all.deb ... 
Unpacking node-form-data (0.1.0-1) ... 
Selecting previously unselected package node-rimraf. 
Preparing to unpack .../node-rimraf_2.2.2-2_all.deb ... 
Unpacking node-rimraf (2.2.2-2) ... 
Selecting previously unselected package node-mkdirp. 
Preparing to unpack .../node-mkdirp_0.3.5-1_all.deb ... 
Unpacking node-mkdirp (0.3.5-1) ... 
Selecting previously unselected package node-graceful-fs. 
Preparing to unpack .../node-graceful-fs_2.0.0-2_all.deb ... 
Unpacking node-graceful-fs (2.0.0-2) ... 
dpkg-deb: error: `/var/cache/apt/archives/node-fstream_0.1.24-1_all.deb' is not a debian format archive 
dpkg: error processing archive /var/cache/apt/archives/node-fstream_0.1.24-1_all.deb (--unpack): 
subprocess dpkg-deb --control returned error exit status 2 
Selecting previously unselected package node-lru-cache. 
Preparing to unpack .../node-lru-cache_2.3.1-1_all.deb ... 
Unpacking node-lru-cache (2.3.1-1) ... 
Selecting previously unselected package node-sigmund. 
Preparing to unpack .../node-sigmund_1.0.0-1_all.deb ... 
Unpacking node-sigmund (1.0.0-1) ... 
Selecting previously unselected package node-minimatch. 
Preparing to unpack .../node-minimatch_0.2.12-1_all.deb ... 
Unpacking node-minimatch (0.2.12-1) ... 
Selecting previously unselected package node-fstream-ignore. 
Preparing to unpack .../node-fstream-ignore_0.0.6-2_all.deb ... 
Unpacking node-fstream-ignore (0.0.6-2) ... 
Selecting previously unselected package node-github-url-from-git. 
Preparing to unpack .../node-github-url-from-git_1.1.1-1_all.deb ... 
Unpacking node-github-url-from-git (1.1.1-1) ... 
Selecting previously unselected package node-glob. 
Preparing to unpack .../node-glob_3.2.6-1_all.deb ... 
Unpacking node-glob (3.2.6-1) ... 
Selecting previously unselected package nodejs-dev. 
Preparing to unpack .../nodejs-dev_0.10.25~dfsg2-2ubuntu1_amd64.deb ... 
Unpacking nodejs-dev (0.10.25~dfsg2-2ubuntu1) ... 
Selecting previously unselected package node-nopt. 
Preparing to unpack .../node-nopt_2.1.2-1_all.deb ... 
Unpacking node-nopt (2.1.2-1) ... 
Selecting previously unselected package node-npmlog. 
Preparing to unpack .../node-npmlog_0.0.4-1_all.deb ... 
Unpacking node-npmlog (0.0.4-1) ... 
Selecting previously unselected package node-osenv. 
Preparing to unpack .../node-osenv_0.0.3-1_all.deb ... 
Unpacking node-osenv (0.0.3-1) ... 
Selecting previously unselected package node-tunnel-agent. 
Preparing to unpack .../node-tunnel-agent_0.3.1-1_all.deb ... 
Unpacking node-tunnel-agent (0.3.1-1) ... 
Selecting previously unselected package node-json-stringify-safe. 
Preparing to unpack .../node-json-stringify-safe_5.0.0-1_all.deb ... 
Unpacking node-json-stringify-safe (5.0.0-1) ... 
Selecting previously unselected package node-qs. 
Preparing to unpack .../node-qs_0.6.5-1_all.deb ... 
Unpacking node-qs (0.6.5-1) ... 
Selecting previously unselected package node-request. 
Preparing to unpack .../node-request_2.26.1-1_all.deb ... 
Unpacking node-request (2.26.1-1) ... 
Selecting previously unselected package node-semver. 
Preparing to unpack .../node-semver_2.1.0-2_all.deb ... 
Unpacking node-semver (2.1.0-2) ... 
Selecting previously unselected package node-tar. 
Preparing to unpack .../node-tar_0.1.18-1_all.deb ... 
Unpacking node-tar (0.1.18-1) ... 
Selecting previously unselected package node-which. 
Preparing to unpack .../node-which_1.0.5-2_all.deb ... 
Unpacking node-which (1.0.5-2) ... 
Selecting previously unselected package node-gyp. 
Preparing to unpack .../node-gyp_0.10.10-2_all.deb ... 
Unpacking node-gyp (0.10.10-2) ... 
Selecting previously unselected package node-ini. 
Preparing to unpack .../node-ini_1.1.0-1_all.deb ... 
Unpacking node-ini (1.1.0-1) ... 
Selecting previously unselected package node-lockfile. 
Preparing to unpack .../node-lockfile_0.4.1-1_all.deb ... 
Unpacking node-lockfile (0.4.1-1) ... 
Selecting previously unselected package node-mute-stream. 
Preparing to unpack .../node-mute-stream_0.0.3-1_all.deb ... 
Unpacking node-mute-stream (0.0.3-1) ... 
Selecting previously unselected package node-normalize-package-data. 
Preparing to unpack .../node-normalize-package-data_0.2.2-1_all.deb ... 
Unpacking node-normalize-package-data (0.2.2-1) ... 
Selecting previously unselected package node-once. 
Preparing to unpack .../node-once_1.1.1-1_all.deb ... 
Unpacking node-once (1.1.1-1) ... 
Selecting previously unselected package node-read. 
Preparing to unpack .../node-read_1.0.4-1_all.deb ... 
Unpacking node-read (1.0.4-1) ... 
Selecting previously unselected package node-read-package-json. 
Preparing to unpack .../node-read-package-json_1.1.3-1_all.deb ... 
Unpacking node-read-package-json (1.1.3-1) ... 
Selecting previously unselected package node-retry. 
Preparing to unpack .../node-retry_0.6.0-1_all.deb ... 
Unpacking node-retry (0.6.0-1) ... 
Selecting previously unselected package node-sha. 
Preparing to unpack .../node-sha_1.2.3-1_all.deb ... 
Unpacking node-sha (1.2.3-1) ... 
Selecting previously unselected package node-slide. 
Preparing to unpack .../node-slide_1.1.4-1_all.deb ... 
Unpacking node-slide (1.1.4-1) ... 
Selecting previously unselected package npm. 
Preparing to unpack .../npm_1.3.10~dfsg-1_all.deb ... 
Unpacking npm (1.3.10~dfsg-1) ... 
Processing triggers for man-db (2.6.7.1-1) ... 
Processing triggers for doc-base (0.10.5) ... 
Processing 4 added doc-base files... 
Errors were encountered while processing: 
/var/cache/apt/archives/node-fstream_0.1.24-1_all.deb 
E: Sub-process /usr/bin/dpkg returned an error code (1) 

當我運行npm install -g mocha時,出現以下錯誤。

用戶@戴爾:〜/ mochatest $

[email protected]:~/mochatest$ npm install -g mocha 
npm ERR! Error: Cannot find module 'fstream' 
npm ERR!  at Function.Module._resolveFilename (module.js:338:15) 
npm ERR!  at Function.Module._load (module.js:280:25) 
npm ERR!  at Module.require (module.js:364:17) 
npm ERR!  at require (module.js:380:17) 
npm ERR!  at Object.<anonymous> (/usr/lib/nodejs/tar/lib/entry.js:14:15) 
npm ERR!  at Module._compile (module.js:456:26) 
npm ERR!  at Object.Module._extensions..js (module.js:474:10) 
npm ERR!  at Module.load (module.js:356:32) 
npm ERR!  at Function.Module._load (module.js:312:12) 
npm ERR!  at Module.require (module.js:364:17) 
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.13.0-36-generic 
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "mocha" 
npm ERR! cwd /home/user//mochatest 
npm ERR! node -v v0.10.25 
npm ERR! npm -v 1.3.10 
npm ERR! code MODULE_NOT_FOUND 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/mochatest/npm-debug.log 
npm ERR! not ok code 0 

回答

0

你需要使用sudo來在Ubuntu安裝全球NPM包。 嘗試

sudo npm install -g mocha 
+0

還是我收到同樣的錯誤,verison的NodeJS是'v0.10.25'和NOP版本是'1.3.10' ' – geeks

+0

它應該工作。在npm有一個類似的錯誤報告。問題記者說重新安裝節點後錯誤消失(https://github.com/npm/npm/issues/3282)。可能想嘗試一下。 – masimplo

+0

在安裝摩卡之前,請嘗試「npm cache clean」 – masimplo