【问题标题】:How to install mocha js for Nodejs?如何为 Nodejs 安装 mocha js?
【发布时间】:2015-09-21 07:36:48
【问题描述】:

在我的 ubuntu 系统上 nodejs 版本是 v0.10.25,nop 版本是 1.3.10。但是当我尝试安装 mochajs 进行测试时,出现以下错误

user@ubuntu:~/mochatest$ sudo 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!     <npm-@googlegroups.com>

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/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

【问题讨论】:

  • 你应该尝试重新安装 NodeJS

标签: node.js npm mocha.js


【解决方案1】:

我不知道您的安装程序要安装哪个版本的 mocha,因为对我来说 mocha 不依赖 fsteam

├─┬ mocha@2.3.3
│ ├── commander@2.3.0
│ ├─┬ debug@2.0.0
│ │ └── ms@0.6.2
│ ├── diff@1.4.0
│ ├── escape-string-regexp@1.0.2
│ ├─┬ glob@3.2.3
│ │ ├── graceful-fs@2.0.3
│ │ ├── inherits@2.0.1
│ │ └─┬ minimatch@0.2.14
│ │   ├── lru-cache@2.7.0
│ │   └── sigmund@1.0.1
│ ├── growl@1.8.1
│ ├─┬ jade@0.26.3
│ │ ├── commander@0.6.1
│ │ └── mkdirp@0.3.0
│ ├─┬ mkdirp@0.5.0
│ │ └── minimist@0.0.8
│ └── supports-color@1.2.0

也许 npm 需要它...尝试使用 npm 安装它,如果它不起作用考虑重新安装 nodejs。

另外,也许相关,你在 MacOS 上吗?如果是这样,请确保 /var/lib/node_modules~/.npm 拥有正确的权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-07
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    相关资源
    最近更新 更多