在 Ubuntu 14.04 上通过 npm 安装 jsdom 的问题

Posted

技术标签:

【中文标题】在 Ubuntu 14.04 上通过 npm 安装 jsdom 的问题【英文标题】:Problems with installing jsdom through npm on Ubuntu 14.04 【发布时间】:2015-05-24 16:30:19 【问题描述】:

我尝试安装 jsdom 以在我正在使用的脚本中使用,但是,我经常遇到错误并且似乎无法在任何地方找到解决方案。大多数人都有没有安装 g++ 的问题,我确实安装了。

不管怎样,这是我的 package.json 文件


  "name": "learning_nodejs",
  "version": "0.0.0",
  "description": "",
  "main": "script.js",
  "dependencies": 
    "optimist": "~0.6.1",
    "jquery": "~2.1.3",
    "jsdom": "*"
  ,
  "devDependencies": ,
  "scripts": 
    "test": "echo \"Error: no test specified\" && exit 1"
  ,
  "author": "",
  "license": "BSD-2-Clause"

然后,如果之前的尝试中存在 node_modules 文件,我将删除它。进入package.json目录,运行npm install

这似乎有点工作,但后来我遇到了一堆错误。这应该足以说明发生了什么:

npm ERR! error rolling back Error: UNKNOWN, unlink '/home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/cssstyle/lib/properties.js'
npm ERR! error rolling back  jsdom@4.0.4  [Error: UNKNOWN, unlink '/home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/cssstyle/lib/properties.js']
npm ERR! error rolling back   errno: -1,
npm ERR! error rolling back   code: 'UNKNOWN',
npm ERR! error rolling back   path: '/home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/cssstyle/lib/properties.js' 
npm ERR! Error: EROFS, symlink '../acorn/bin/acorn'
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-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path ../acorn/bin/acorn
npm ERR! code EROFS
npm ERR! errno 56
npm ERR! Error: ENOENT, lstat '/home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/parse5/lib/tree_construction/doctype.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.13.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/parse5/lib/tree_construction/doctype.js
npm ERR! fstream_path /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/parse5/lib/tree_construction/doctype.js

...

npm ERR! System Linux 3.13.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test
npm ERR! fstream_path /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/node_modules/jsdom/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/common.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call setupMadeDir
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack end (/usr/lib/nodejs/fstream/lib/writer.js:319:21)
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:336:20
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:358:20
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm WARN optional dep failed, continuing source-map@0.1.43
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/daniel/Desktop/virtual_share/javascript_stuff/learning_nodejs/npm-debug.log
npm ERR! not ok code 0

无论如何,我觉得这与我的投影位于 Ubuntu 14.04(虚拟化)和我的主机操作系统之间的已安装共享驱动器上的事实有关。

提前致谢

【问题讨论】:

【参考方案1】:

找到了解决办法!

This page is very helpful

基本上,这确实是因为共享文件,但只需添加 --no-bin-links 即可修复它。希望这可以帮助某人!

【讨论】:

以上是关于在 Ubuntu 14.04 上通过 npm 安装 jsdom 的问题的主要内容,如果未能解决你的问题,请参考以下文章

npm 全局安装后如何在 Virtual Box Ubuntu 14.04 中修复 $PATH

ubuntu 14.04 安装npm

ubuntu14.04 nodejs安装位置在哪

win7下通过easyBCD引导安装Ubuntu14.04

Ubuntu14.04LTS上安装Pip

如何在ubuntu 安装nodejs