首页 文章

npm在Windows上安装jsdom错误?

提问于
浏览
12

我已经在我的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”重建信息,如果它以好的ERR!错误:似乎没有在Object.oncomplete(C:\ Program Files)的failNoPython(C:\ Program Files \ nodejs \ node_modules \ npm \ node_modules \ node-gyp \ lib \ configure.js:78:14)中安装Python \ 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

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

7 回答

  • 1

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

    • 安装Visual Studio 2010/2012 C(Express或更高版本)

    • 安装Windows SDK 7.1

    • 安装"Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1"

    • 安装GTK(C:\ GTK)

    • 安装Python(C:\ Python27)

    • 安装node.js(x86)

    • 将[node.js]添加到路径(C:\ Program Files(x86)\ nodejs ;)

    • 将[python]添加到路径(C:\ Python27 ;)

    • 将[GTK]添加到路径(C:\ GTK \ bin;)

    • 添加指向"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin"的[WindowsSDKDir]系统变量

    • 以管理员身份运行"Windows SDK 7.1 Command Prompt"

    • 使用"setenv /x86"将环境设置为x86

    • 将目录更改为"C:\Program Files (x86)\nodejs"

    • 运行"npm install -g npm"

    • 运行"npm update -g npm"

    • 运行"npm install -g node-gyp"

    • 运行"node-gyp configure build"

    • 运行"npm install jsdom"

    • 运行"npm install ajax"

    • 运行"npm install http-server"

    • 运行"npm install jquery"

    • 运行"npm install xmlhttprequest"

    • 运行"npm update"

    我希望这有帮助 .

  • 1

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

  • 0

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

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

    npm install -g node-gyp
    node-gyp configure
    
  • 0

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

    首先,安装Visual Studio 2012

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

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

    jsdom 使用 contextify 在DOM上运行JavaScript . 并且 contextify 需要本机C编译器 . 根据the official readme,在Windows平台上,必须安装:

    • 适用于Windows的x86版本的Node.js的最新副本,而不是x64版本 . (默认情况下应该没问题)

    • Visual C 2010 Express的副本 . (或任何更新的版本)

    • Python 2.7的副本,安装在 C:\Python27 的默认位置 .

  • 3

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

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

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

    然后:

    node-gyp configure

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

  • 14

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

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

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

    所以我只是这样做:

    • 从MS中删除了我安装过一次的所有程序 .

    • 已卸载 Nodejs

    • 我确定用CCleaner清理了注册表

    • 删除了与Node.js相关的Python,Node-gyp和其他应用程序

    然后我重新安装了对JSdom乐观的Node.js,它正确安装,但在运行我的项目时崩溃了 . 所以我搜索了新的错误 - 再次 - 有一个简单的解决方案 . I had to install an older version of JSdom.

    npm install jsdom@4.2.0
    

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

相关问题