node.js - Node 看不到包,路径错误

标签 node.js path npm

我正在尝试设置和运行 microtime package ,但 Node 引发错误:

npm install microtime

ubuntu@ubuntu-desktop:~$ node
> var microtime = require('microtime')
Error: Could not load the bindings file. Tried:
 -> /home/ubuntu/node_modules/microtime/build/Debug/microtime.node
 -> /home/ubuntu/node_modules/microtime/build/Release/microtime.node
 -> /home/ubuntu/node_modules/microtime/out/Debug/microtime.node
 -> /home/ubuntu/node_modules/microtime/Debug/microtime.node
 -> /home/ubuntu/node_modules/microtime/out/Release/microtime.node
 -> /home/ubuntu/node_modules/microtime/Release/microtime.node
 -> /home/ubuntu/node_modules/microtime/build/default/microtime.node
 -> /home/ubuntu/node_modules/microtime/compiled/0.6/linux/ia32/microtime.node
    at bindings (/home/ubuntu/node_modules/microtime/node_modules/bindings/bindings.js:82:13)
    at Object.<anonymous> (/home/ubuntu/node_modules/microtime/index.js:1:95)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at repl:1:17
    at REPLServer.eval (repl.js:80:21)

路径似乎有问题,但我不知道去哪里挖掘来解决这个问题(我是 linux 新手)

我的配置是:ubuntu 10.04,node 0.6.13,npm 1.1.10

2@Linus:嗯,我刚刚尝试重新安装 microtime,现在出现错误(但第一次不是):

ubuntu@ubuntu-desktop:~/app1$ npm install microtime
npm http GET https://registry.npmjs.org/microtime
npm http 304 https://registry.npmjs.org/microtime
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings

> microtime@0.3.1 install /home/ubuntu/node_modules/microtime
> node-gyp rebuild

info it worked if it ends with ok 
spawn python [ '/home/ubuntu/.node-gyp/0.6.13/tools/gyp_addon',
  'binding.gyp',
  '-I/home/ubuntu/node_modules/microtime/build/config.gypi',
  '-f',
  'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/ubuntu/node_modules/microtime/build'
  CXX(target) Release/obj.target/microtime/src/microtime.o
make: g++: Command not found
make: *** [Release/obj.target/microtime/src/microtime.o] Error 127
make: Leaving directory `/home/ubuntu/node_modules/microtime/build'
ERR! Error: `make` failed with exit code: 2
    at Array.0 (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:169:25)
    at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok

npm ERR! microtime@0.3.1 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the microtime@0.3.1 install script.
npm ERR! This is most likely a problem with the microtime package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls microtime
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 2.6.32-21-generic
npm ERR! command "node" "/usr/bin/npm" "install" "microtime"
npm ERR! cwd /home/ubuntu/app1
npm ERR! node -v v0.6.13
npm ERR! npm -v 1.1.10
npm ERR! code ELIFECYCLE
npm ERR! message microtime@0.3.1 install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ubuntu/app1/npm-debug.log
npm not ok

最佳答案

这是您问题的根源:

make: g++: Command not found

你需要

apt-get install build-essential

然后尝试重新安装。对您的发行版使用 sudo 或 super 用户来执行此操作。

关于node.js - Node 看不到包,路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9807081/

相关文章:

node.js - socket.io - 传输关闭

javascript - 无法在 Node.js 中使用 ECDH 私钥签署缓冲区

javascript - 为什么在 JavaScript 注释中使用 '@' - @param

包内资源的 Android 路径

node.js - 仅需要一个模块(如果已安装)

node.js - 将 SASS 与 ReactJS 和 Webpack 结合使用

javascript - 如何在运行在 node.js 上的脚本中使用 jsdoc?

java - 如何更改 Eclipse Plugin 项目中 IWorkspaceRoot 的路径

node.js - 未找到命令 : nodemon --- need helping adding directory to PATH

node.js - 带有第二个 package.json 的模式实验室