npm安装失败使用babel-presets / chai / mocha

时间:2015-11-05 05:12:22

标签: node.js npm mocha babeljs chai

在Ubuntu 14.04.3 LTS上使用Node v0.10.40和NPM 1.4.28

npm install失败了,我甚至没有在node_modules/.bin得到我所期望的所有软链接。

这似乎与chaiwebpackwebpack-dev-serverbabel-preset-es2015 / babel-preset-react有关。如果我把Chai拿出去就可以了。如果我拿出babel预设的套餐就行了。如果他们都在那里,那就没有。

最小破损packages.json

这是一个小的packages.json配置,它打破了:

{
  "name": "voting-client",
  "version": "1.0.0",
  "description": "",
  "main": "index.jsx",
  "scripts": {
    "webpack": "webpack",
    "webpack-dev-server": "webpack-dev-server --host 0.0.0.0",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'",
    "test:watch": "npm run test --watch"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.0.20",
    "babel-loader": "^6.0.1",
    "babel-preset-es2015": "^6.0.15",
    "babel-preset-react": "^6.0.15",
    "chai": "^3.4.0",
    "mocha": "^2.3.3",
    "webpack": "^1.12.2",
    "webpack-dev-server": "^1.12.1"
  },
  "dependencies": {
  }
}

实际packages.json

这是我的实际packages.json配置也破坏了:

{
  "name": "voting-client",
  "version": "1.0.0",
  "description": "",
  "main": "index.jsx",
  "scripts": {
    "webpack": "webpack",
    "webpack-dev-server": "webpack-dev-server --host 0.0.0.0",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'",
    "test:watch": "npm run test --watch"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.0.20",
    "babel-loader": "^6.0.1",
    "babel-preset-es2015": "^6.0.15",
    "babel-preset-react": "^6.0.15",
    "chai": "^3.4.0",
    "chai-immutable": "^1.5.1",
    "jsdom": "^7.0.2",
    "mocha": "^2.3.3",
    "react-hot-loader": "^1.3.0",
    "webpack": "^1.12.2",
    "webpack-dev-server": "^1.12.1"
  },
  "dependencies": {
    "immutable": "^3.7.5",
    "react": "^0.14.2",
    "react-dom": "^0.14.2"
  }
}

来自npm install的错误

仔细查看npm install我可以看到它在子包utf-8-validate上失败了。我知道我的吉普赛安装有效,因为它在另一个项目中编译socket.io没问题。

web23@wendy:/var/www/io.ofbeaton.com/web/dev/voting-client$ npm install
npm WARN package.json voting-client@1.0.0 No description
npm WARN package.json voting-client@1.0.0 No repository field.
npm WARN package.json voting-client@1.0.0 No README data
npm WARN optional dep failed, continuing fsevents@1.0.5
npm WARN optional dep failed, continuing fsevents@1.0.5
\
> utf-8-validate@1.2.1 install /var/www/clients/client1/web23/web/dev/voting-client/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate
> node-gyp rebuild

make: Entering directory `/var/www/clients/client1/web23/web/dev/voting-client/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate/build'
  CXX(target) Release/obj.target/validation/src/validation.o
Killed
web23@wendy:/var/www/io.ofbeaton.com/web/dev/voting-client$   SOLINK_MODULE(target) Release/obj.target/validation.node
  SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
  COPY Release/validation.node
make: Leaving directory `/var/www/clients/client1/web23/web/dev/voting-client/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate/build'

特别参见Killed行。这就是我在破损的安装上得到的所有输出。这是怎么回事?我该如何解决?

没有预设的工作示例:

这是一个没有babel-presets的工作package.json

{
  "name": "voting-client",
  "version": "1.0.0",
  "description": "",
  "main": "index.jsx",
  "scripts": {
    "webpack": "webpack",
    "webpack-dev-server": "webpack-dev-server --host 0.0.0.0",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'",
    "test:watch": "npm run test --watch"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.0.20",
    "babel-loader": "^6.0.1",   
    "chai": "^3.4.0",
    "mocha": "^2.3.3",
    "webpack": "^1.12.2",
    "webpack-dev-server": "^1.12.1"
  },
  "dependencies": {
  }
}

编辑:问题是旧节点版本吗?

https://github.com/websockets/utf-8-validate/issues/18似乎表明旧节点版本会导致此问题。

所以我将节点升级到v5.0.0,将npm升级到3.3.6。

这是'npm install'输出:

web23@wendy:/var/www/io.ofbeaton.com/web/dev/voting-client$ npm install
npm WARN install Couldn't install optional dependency: Unsupported
extract → gunzTarPerm     ▐ ╢█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
Killed

没有骰子。

1 个答案:

答案 0 :(得分:0)

在旧版本的节点上编译时,第一个问题确实是utf-8-validate问题。为此我遵循digitalocean guide使用v5.0.0版本。请注意,我必须抓取setup_5.x文件,而不是指南中描述的setup文件。

接下来的问题是,在Killed执行时,我收到了npm install消息。这是因为我运行的机器不到512mb的RAM和256mb的交换。这听起来非常小,但它是一个简单的ubuntu服务器,完全符合最低规格,并作为数据中心的VM运行。我可以一次安装一个包,但一次安装就会耗尽内存,并生成Killed消息。唯一的解决方案是增加我的内存和交换,或在另一台机器上运行并上传文件。不理想,但他们是休息。

我现在已经正常工作了。