繁体   English   中英

npm在Windows上安装jsdom错误?

[英]npm install jsdom error on windows?

我已经在我的Windows PC上安装了nodejs。 它工作正常。 但是当我尝试使用“npm install jsdom”安装jsdom时,我被这个错误提示。

节点“C:\\ Program Files \\ nodejs \\ node_modules \\ npm \\ bin \\ node-gyp-bin \\ .... \\ node_modules \\ node-gyp \\ bin \\ node-gyp.js”重建信息,如果它以ok结束它是否有效
呃! 错误:似乎没有安装Python
在object.oncomplete的failNoPython(C:\\ Program Files \\ nodejs \\ node_modules \\ npm \\ node_modules \\ node-gyp \\ lib \\ configure.js:78:14)中(C:\\ Program Files \\ nodejs \\ node_modules \\ npm \\ node_modules \\ node-gyp \\ lib \\ configure.js:66:11)ERR! 不好
npm WARN可选依赖失败,继续contextify@0.1.2
jsdom@0.2.13 ./node_modules/jsdom
+ - cssom@0.2.3 + - htmlparser@1.7.5

有人可以帮我解决这个问题吗?

我在Windows 7(x64 Ultimate)上遇到了同样的问题,经过数小时的搜索和试用,我就是这样解决的。 请按照相同的顺序执行以下步骤:

  1. 安装Visual Studio 2010/2012 C ++(Express或更高版本)
  2. 安装Windows SDK 7.1
  3. 安装“Windows SDK 7.1的Microsoft Visual C ++ 2010 Service Pack 1编译器更新”
  4. 安装GTK(C:\\ GTK)
  5. 安装Python(C:\\ Python27)
  6. 安装node.js(x86)
  7. 将[node.js]添加到路径(C:\\ Program Files(x86)\\ nodejs \\;)
  8. 将[python]添加到路径(C:\\ Python27 \\;)
  9. 将[GTK]添加到路径(C:\\ GTK \\ bin;)
  10. 添加指向“C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v7.1 \\ Bin”的[WindowsSDKDir]系统变量
  11. 以管理员身份运行“Windows SDK 7.1命令提示符”
  12. 使用“setenv / x86”将环境设置为x86
  13. 将目录更改为“C:\\ Program Files(x86)\\ nodejs \\”
  14. 运行“npm install -g npm”
  15. 运行“npm update -g npm”
  16. 运行“npm install -g node-gyp”
  17. 运行“node-gyp configure build”
  18. 运行“npm install jsdom”
  19. 运行“npm install ajax”
  20. 运行“npm install http-server”
  21. 运行“npm install jquery”
  22. 运行“npm install xmlhttprequest”
  23. 运行“npm update”

我希望这有帮助。

这里有一个很好的指南让JSDom在Windows上工作: http//www.steveworkman.com/node-js/2012/installing-jsdom-on-windows/

对于Windows 8 64位,安装zmq和protobuf,以下对我有用:

首先,安装Visual Studio 2012

然后,在命令提示符下(在项目目录中):

SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf
npm install jsdom

jsdom使用contextify在DOM上运行JavaScript。 contextify需要本机C ++编译器。 根据官方自述文件 ,在Windows平台上,必须安装:

  1. 用于Windows的x86版本的Node.js的最新副本,而不是x64版本。 (默认情况下应该没问题)
  2. Visual C ++ 2010 Express的副本。 (或任何更新的版本)
  3. Python 2.7的副本,安装在C:\\Python27的默认位置。

jsdom依赖于contextify,它最近才支持windows。 你需要python和C ++编译器才能安装它。

您可能还需要执行以下操作

npm install -g node-gyp
node-gyp configure

如果已经安装了python,则需要将python安装目录添加到PATH环境变量中。

假设python.exe位于C:\\Python32\\目录中,在DOS提示符下需要输入:

set PATH=%PATH%;C:\\Python32\\;

然后:

node-gyp configure

没有那个错误应该可以正常工作

经过近半年的解决这个问题,阅读与此相关的所有论坛,我终于找到了解决方案。

在我的案例中,我所做的很简单,因为我在这台电脑上没有使用很多应用程序。

我的Windows 8.1安装了许多程序,可能会混淆NodeJS(Frameworks,VS插件等)。

所以我只是这样做:

  • 从MS中删除了我安装过的所有程序。
  • 卸载的Nodejs
  • 我肯定用CCleaner清理了注册表
  • 删除了与Node.js相关的Python,Node-gyp和其他应用程序

然后我重新安装了对JSdom乐观的Node.js,它正确安装,但在运行我的项目时崩溃了。 所以我搜索了新的错误 - 再次 - 有一个简单的解决方案。 我不得不安装旧版的JSdom。

npm install jsdom@4.2.0

最后,一切正常。 希望能帮助任何人解决这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM