1

我正在尝试在 Windows 7 上为 Node.js 安装 johnny 5 库,但不断收到错误消息:

Your environment has been set up for using Node.js 0.10.15 (x64) and npm.

C:\Users\User>npm install johnny-five
npm http GET https://registry.npmjs.org/johnny-five
npm http 304 https://registry.npmjs.org/johnny-five
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/firmata
npm http GET https://registry.npmjs.org/es6-collections
npm http GET https://registry.npmjs.org/descriptor
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/compulsive
npm http GET https://registry.npmjs.org/serialport
npm http GET https://registry.npmjs.org/temporal
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/colors
npm http 304 https://registry.npmjs.org/firmata
npm http 304 https://registry.npmjs.org/es6-collections
npm http 304 https://registry.npmjs.org/descriptor
npm http 304 https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/compulsive
npm http 304 https://registry.npmjs.org/serialport
npm http 304 https://registry.npmjs.org/temporal
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/socket.io
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/socket.io-client/0.9.16
npm http GET https://registry.npmjs.org/base64id/0.1.0
npm http GET https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/redis/0.7.3
npm http GET https://registry.npmjs.org/bindings/1.1.0
npm http GET https://registry.npmjs.org/async/0.1.18
npm http GET https://registry.npmjs.org/sf/0.1.6
npm http 304 https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/policyfile/0.0.4
npm http 304 https://registry.npmjs.org/base64id/0.1.0
npm http 304 https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.16
npm http GET https://registry.npmjs.org/socket.io-client/-/socket.io-client-0.9.
16.tgz
npm http 304 https://registry.npmjs.org/bindings/1.1.0
npm http 304 https://registry.npmjs.org/async/0.1.18
npm http 304 https://registry.npmjs.org/sf/0.1.6

> serialport@1.1.3 install C:\Users\User\node_modules\johnny-five\node_modules
\serialport
> node-gyp rebuild


C:\Users\User\node_modules\johnny-five\node_modules\serialport>node "C:\Progra
m Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bi
n\node-gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Command failed: ImportError: No module named site
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:637:15)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at maybeClose (child_process.js:735:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:802:
5)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\User\node_modules\johnny-five\node_modules\serialport
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.10.6
gyp ERR! not ok
npm ERR! weird error 1
npm http 200 https://registry.npmjs.org/socket.io-client/-/socket.io-client-0.9.
16.tgz
npm ERR! not ok code 0

我在mac上遇到了同样的问题,但是按照上一篇文章的建议通过安装xcode命令行组件解决了这个问题,但不知道如何在windows上解决这个问题。

谢谢你的帮助!

4

4 回答 4

1

(这与欧文的回答非常相似,只是添加了一些陷阱 - 但我还不能评论,所以......)

我刚刚在 Windows 8 上进行了这项工作,但怀疑其中大部分也适用于 Win7:

对于 arduino 本身,记得检查驱动程序(http://arduino.cc/en/Guide/windows),我必须将 com 端口提供给 Johnny 五(https://github.com/rwaldron/johnny-five /blob/master/docs/board-with-port.md)。

于 2013-09-05T14:48:00.157 回答
1

好的,我在 Windows 中遇到了类似的问题。您必须安装 visual studio 2012/2010 。我安装了 Vs2012 所以我用开关运行了 npm 命令

npm install johnny-five --msvs_version=2012 

这为我解决了这个问题。基本上,johnny 5 中的 serialport 包需要为操作系统重建自身,因此它需要运行 nodegyp 包,该包将查找 MSBuild

于 2013-11-21T05:53:19.290 回答
0

我不确定您的具体错误,但在我卸载所有 Visual Studio 产品并按照https://github.com/TooTallNate/node-gyp上的说明操作之前,我在 Windows 上安装 npm 时遇到了很多与 node-gyp 相关的不同错误到 T。这特别包括 Visual Studio 2010(不是 2012 不起作用)、SDK 和 SDK 更新。在我完全按照这些步骤操作后,我不再出现错误(包括几分钟前成功测试安装的强尼五号。如果您还没有遵循这些步骤,也许值得一试。

于 2013-08-03T19:03:18.457 回答
0

确保您拥有运行所需的所有软件node-gyp

您可以gyp通过环境变量配置所使用的 Visual Studio 版本,这样您就可以避免设置--msvs_version=2012属性。

例子:

  • GYP_MSVS_VERSION=2012为 Visual Studio 2012设置
  • 设置GYP_MSVS_VERSION=2013e(“e”代表“特快版”)

有关完整列表,请参阅 - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

这对于 NodeJS 的 Windows 用户来说仍然很痛苦,因为它假定您安装了 Python 和 Visual Studio 的副本,而许多最终用户永远不会拥有这个。因此,我正在游说 Joyent 鼓励他们将 Web 套接字作为 CORE 节点的一部分,并可能将 GNU gcc 编译器作为 NodeJS 安装的一部分,这样我们就可以永久解决这个问题。

欢迎在以下位置添加您的投票:

于 2014-08-01T01:40:30.160 回答