【问题标题】:Failed at the phantomjs-prebuilt@2.1.13 install script 'node install.js'phantomjs-prebuilt@2.1.13 安装脚本“node install.js”失败
【发布时间】:2016-12-06 09:44:23
【问题描述】:

我正在尝试在 Windows 7 机器上安装 phantomjs 并收到此错误。

npm ERR! Windows_NT 6.1.7601  
npm ERR! argv "C:\\Program Files (x86)\\nodist\\v\\nodev5.5.0\\node.exe"   "C:\\Program Files (x86)\\nodist\\bin\\node_mod  
ules\\npm\\bin\\npm-cli.js" "install"  
npm ERR! node v5.5.0  
npm ERR! npm  v3.10.9  
npm ERR! code ELIFECYCLE  

npm ERR! phantomjs-prebuilt@2.1.13 install: `node install.js`  
npm ERR! Exit status 1  
npm ERR!  
npm ERR! Failed at the phantomjs-prebuilt@2.1.13 install script 'node   install.js'.  
npm ERR! Make sure you have the latest version of node.js and npm installed.

在 phantomjs github 存储库中记录了许多相同或 this SO 问题的问题,但对我的情况没有任何帮助。

这是我机器的状态

  • 我在 C:\npm\phantomjs-2.1.1-windows\bin\phantomjs.exe 本地安装了 phantomjs,但是当我运行 npm install 时,它总是会尝试通过下载来安装这就是我的问题所在。我的公司代理阻止了直接下载。我也不能使用这里提到的--phantomjs_cdnurl 开关https://www.npmjs.com/package/phantomjs#deciding-where-to-get-phantomjs
  • 我可以运行该命令,它工作正常 phantomjs -v
    2.1.1

但是当我在我的项目上运行 npm install 时,它正在尝试安装 phantomjs 并且会遇到上述错误。我从 npm 日志中观察到的另一件事

Considering PhantomJS found at C:\Program Files (x86)\nodist\bin\phantomjs.CMD Found PhantomJS at C:\Program Files (x86)\nodist\bin\phantomjs.CMD ...verifying Error verifying phantomjs, continuing { [Error: Command failed: C:\Program Files (x86)\nodist\bin\phantomjs.CMD --version

它正在尝试运行同样失败的 phantomjs.CMD --version

Error verifying phantomjs, continuing { [Error: Command failed: C:\Program Files (x86)\nodist\bin\phantomjs.CMD --versio
n
internal/child_process.js:274
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:274:26)
    at exports.spawn (child_process.js:362:9)
    at Object.<anonymous> (C:\Program Files (x86)\nodist\bin\node_modules\phantomjs-prebuilt\bin\phantomjs:22:10)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
]
  killed: false,
  code: 1,
  signal: null,
  cmd: 'C:\\Program Files (x86)\\nodist\\bin\\phantomjs.CMD --version' }

【问题讨论】:

    标签: node.js phantomjs


    【解决方案1】:

    作为临时解决方法,我可以使用 --ignore-scripts 安装它

    npm install phantomjs-prebuilt@2.1.13 --ignore-scripts

    我还在 github 存储库中记录了一个问题

    https://github.com/Medium/phantomjs/issues/649

    已编辑

    这个问题是我正在使用的构建过程脚本的一部分,它每次都会执行 npm clean 并安装很多其他东西。所以这个问题在我们使用 phantomjs 进行自动化测试的同一台机器上出现了很多次。我有一些时间来研究这个问题,似乎我的公司代理阻止了来自 https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip 的下载。我之前就知道这一点,并手动安装了 phantomjs 二进制文件并添加到系统路径,但 npm install 仍然尝试在本地下载,如下面的日志所示。

    Considering PhantomJS found at C:\npm\phantomjs-2.1.1-windows\bin\phantomjs.EXE
    Looks like an `npm install -g` on windows; skipping installed version.
    

    我的公司代理也阻止了所有 phantomjs CDN url (https://www.npmjs.com/package/phantomjs)

    我使用的解决方法是获取 phantomjs-2.1.1-windows.zip 并将其复制到 C:\Users\\AppData\Local\Temp \phantomjs\phantomjs-2.1.1-windows.zip 并解决了构建脚本的问题。如果有人清理临时目录,问题会回来。即使这是一种解决方法,但由于显而易见的原因,无法解除对公司代理的阻止:)

    希望这对某人有所帮助!

    【讨论】:

    • 谢谢,使用 --ignore-scripts 对我有用,而其他提供的解决方案都没有:)
    • --ignore-scripts 甚至可以在 Jenkins nodejs 工具配置中工作(要安装的全局 npm 包)。如果没有这个设置,Jenkins 每次都重新安装软件包,可能是由于错误。
    【解决方案2】:

    我遇到了同样的错误,它会通过以下更改解决,希望对您有所帮助。

    sudo npm install phantomjs-prebuilt@2.1.13 --unsafe-perm
    

    【讨论】:

      【解决方案3】:

      有时当我们尝试在本地安装 phantomjs 时,它会起作用。但是对于全局,我建议你输入

      sudo npm install -g phantomjs-prebuilt --unsafe-perm
      

      【讨论】:

        【解决方案4】:

        请删除您系统中连接的所有 vpn。我删除了office vpn,然后点击npm install,它对我来说很好。

        【讨论】:

        • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
        【解决方案5】:

        所有这些解决方案都没有帮助我

        --ignore-scripts 有帮助,但最终安装的 phantomjs 无法运行,我的业力测试无法使用 phantomjs 浏览器。

        但是我找到了适用于我的 Win 机器的解决方案。我从https://phantomjs.org/download.html下载了带有.exe文件的distribute,然后在本地解压(可以是任何文件夹):

        然后添加到: set Path=;C:\Users\admin\AppData\Roaming\phantomjs-2.1.1-windows\bin;$Path

        之后,'npm install' 可以重新使用它:

         [exec] > node install.js
        
         [exec] 
        
         [exec] Considering PhantomJS found at C:\Users\admin\AppData\Roaming\phantomjs-2.1.1-windows\bin\phantomjs.EXE
        
         [exec] Found PhantomJS at C:\Users\admin\AppData\Roaming\phantomjs-2.1.1-windows\bin\phantomjs.EXE ...verifying
        
         [exec] Writing location.js file
        
         [exec] PhantomJS is already installed on PATH at C:\Users\admin\AppData\Roaming\phantomjs-2.1.1-windows\bin\phantomjs.EXE
        
         [exec] 
        
         [exec] > phantomjs@2.1.7 install C:\xxx\client\ui\src\main\web\build\node_modules\phantomjs
         [exec] > node install.js
        

        【讨论】:

          猜你喜欢
          • 2017-03-29
          • 1970-01-01
          • 2023-03-17
          • 1970-01-01
          • 2020-10-19
          • 2020-01-25
          • 2018-11-06
          • 2021-05-01
          • 1970-01-01
          相关资源
          最近更新 更多