Phantomjs Yeoman生成器总是会出错

Phantomjs Yeoman生成器总是会出错,phantomjs,yeoman,yeoman-generator,Phantomjs,Yeoman,Yeoman Generator,当我尝试使用yeoman web generator时,虽然它工作正常,但纵观整个生成过程,它总是给我以下一些错误,无论我使用的是什么生成器,它们总是存在 npm ERR! phantomjs@1.9.7-6 install: `node install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the phantomjs@1.9.7-6 install script. npm ERR! This is most likely

当我尝试使用yeoman web generator时,虽然它工作正常,但纵观整个生成过程,它总是给我以下一些错误,无论我使用的是什么生成器,它们总是存在

npm ERR! phantomjs@1.9.7-6 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the phantomjs@1.9.7-6 install script.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls phantomjs
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Applications/MAMP/htdocs/DECO3800/test
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.10
npm ERR! code ELIFECYCLE

npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Applications/MAMP/htdocs/DECO3800/test/npm-debug.log
npm ERR! not ok code 0

只是想知道为什么会这样,以及如何解决它,或者它完全不影响我构建的web项目?

我也有同样的问题,我遇到过这样一个问题,有人声称他找到了解决类似问题的方法:

“这里也一样,通过从下载到它试图保存它的路径使其工作。bitbucket回购最近是否在私有/公共之间切换?”

看起来phantomjs下载不再有效(或类似);事实上,许多人在同一时间都有同样的问题,这表明情况可能就是这样


我不知道如何继续,但这可能会为您指明正确的方向。

目前Bitbucket CDN似乎存在问题

您可以将其用作临时解决方法:

PHANTOMJS_CDNURL=http://cnpmjs.org/downloads npm install phantomjs

提到的解决办法是:

您可以在此处手动下载phantomjs zip:并将其移动到npm希望下载到的目录

Downloading http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-macosx.zip Saving to /var/folders/fl/ssqg11_j1hs5mk4fvyqgjcmc0000gn/T/phantomjs/phantomjs-1.9.7-macosx.zip . . 正在下载http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-macosx.zip 保存到/var/folders/fl/ssqg11_j1hs5mk4fvyqgjcmc000gn/T/phantomjs/phantomjs-1.9.7-macosx.zip . .
每当您下次尝试构建项目时,phantomjs已经存在并且不必下载,因此将跳过下载,项目将完成(除非遇到其他错误)。

使用以下设置遇到类似问题:

  • Windows 7 x64
  • 节点v0.10.32
  • npm v2.5.0
  • 约曼v1.3.2
  • grunt cli v0.1.13
  • grunt html快照v0.6.1(grunt html快照也有同样的问题)
  • grunt lib phantomjs v0.3.0(grunt html快照的依赖性)
  • phantomjs v1.9.15(依赖于grunt lib phantomjs)
不那么重要的是:

  • 鲍尔v1.3.12
  • GitV1.9.4.msysgit.2
错误:

phantomjs@1.9.15 install d:\TEST\a111\node_modules\grunt-html-s
napshot\node_modules\grunt-lib-phantomjs\node_modules\phantomjs
node install.js

Download already available at C:\Users\USER~1\AppData\Local\Temp\phantomjs\phan
tomjs-1.9.8-windows.zip
Extracting zip contents
Removing d:\TEST\a111\node_modules\grunt-html-snapshot\node_modul
es\grunt-lib-phantomjs\node_modules\phantomjs\lib\phantom
Copying extracted folder C:\Users\USER~1\AppData\Local\Temp\phantomjs\phantomjs
-1.9.8-windows.zip-extract-1424937053563\phantomjs-1.9.8-windows -> d:\SVN\DBITS
\Web\B-RAD\a111\node_modules\grunt-html-snapshot\node_modules\grunt-lib-phantomj
s\node_modules\phantomjs\lib\phantom
Writing location.js file
Phantom installation failed { [Error: EPERM, operation not permitted 'd:\SVN\DBI
TS\Web\B-RAD\a111\node_modules\grunt-html-snapshot\node_modules\grunt-lib-phanto
mjs\node_modules\phantomjs\lib\phantom\phantomjs.exe']
  errno: 50,
  code: 'EPERM',
  path: 'd:\\SVN\\DBITS\\Web\\B-RAD\\a111\\node_modules\\grunt-html-snapshot\\no
de_modules\\grunt-lib-phantomjs\\node_modules\\phantomjs\\lib\\phantom\\phantomj
s.exe',
  syscall: 'chmod' } Error: EPERM, operation not permitted 'd:\SVN\DBITS\Web\B-R
AD\a111\node_modules\grunt-html-snapshot\node_modules\grunt-lib-phantomjs\node_m
odules\phantomjs\lib\phantom\phantomjs.exe'
    at Object.fs.chmodSync (evalmachine.<anonymous>:832:18)
    at Object.chmodSync (d:\TEST\a111\node_modules\grunt-html-sna
pshot\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\node_modules\fs-ex
tra\node_modules\graceful-fs\polyfills.js:141:17)
    at Promise.validExit [as _successFn] (d:\TEST\a111\node_modul
es\grunt-html-snapshot\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\i
nstall.js:145:8)
    at Promise._call (d:\TEST\a111\node_modules\grunt-html-snapsh
ot\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\node_modules\kew\kew.
js:373:13)
    at Promise._withInput (d:\TEST\a111\node_modules\grunt-html-s
napshot\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\node_modules\kew
\kew.js:333:25)
    at Promise.resolve (d:\TEST\a111\node_modules\grunt-html-snap
shot\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\node_modules\kew\ke
w.js:105:27)
    at resolver (d:\TEST\a111\node_modules\grunt-html-snapshot\no
de_modules\grunt-lib-phantomjs\node_modules\phantomjs\node_modules\kew\kew.js:40
9:17)
    at CB (d:\TEST\a111\node_modules\grunt-html-snapshot\node_mod
ules\grunt-lib-phantomjs\node_modules\phantomjs\node_modules\fs-extra\node_modul
es\rimraf\rimraf.js:68:5)
    at Object.oncomplete (fs.js:107:15)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-html-snapshot"
npm ERR! node v0.10.32
npm ERR! npm  v2.5.0
npm ERR! code ELIFECYCLE

npm ERR! phantomjs@1.9.15 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs@1.9.15 install script 'node install.js'.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls phantomjs
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     d:\TEST\a111\npm-debug.log
我也试过了,但没有一个解决了我的问题

然后,当我尝试使用gitbash中的npm install命令在一个空文件夹中安装phantomjs时,它在没有任何错误的情况下反复安装

$ npm install phantomjs
OR
$ npm install phantomjs@v1.9.15
当我使用grunt lib phantomjs执行此操作时,10次中有3次出现相同的错误

$ npm install grunt-lib-phantomjs
OR
$ npm install grunt-lib-phantomjs@0.3.0
$ npm install grunt-html-snapshot
OR
$ npm install grunt-html-snapshot@0.6.1
当我使用grunt html快照执行此操作时,10次中有10次出现相同的错误

$ npm install grunt-lib-phantomjs
OR
$ npm install grunt-lib-phantomjs@0.3.0
$ npm install grunt-html-snapshot
OR
$ npm install grunt-html-snapshot@0.6.1
这让我思考。我在一个新文件夹上安装了带有npm的phantomjs,并运行了生成器。这导致安装没有10个错误

$ npm install grunt-lib-phantomjs
OR
$ npm install grunt-lib-phantomjs@0.3.0
$ npm install grunt-html-snapshot
OR
$ npm install grunt-html-snapshot@0.6.1
为了让生成器完成整个安装,我在生成器的优先级下添加了phantomjs的安装,该生成器是在安装其他npm之前安装的舒尔

conflicts: function () {
    var self = this,
        done = self.async();
    self.log(msgStepStart('------- 6: Handeling Conflicts! -------'));

    self.npmInstall([
        'phantomjs@1.9.15',
    ], {}, function() {
        done();
        self.log(msgStepEnd('------- 6: I handled the conflicts! -------'));
    });
},
这完全解决了我的问题,希望对其他人有所帮助

附言:

如果您使用任何类型的版本控制,而不包括已部署项目的已安装节点\ U模块。你可以考虑在你的结束方法中使用下面的生成器优先级。
end: function () {
    var self = this,
        done = self.async();
    self.log(msgStepStart('------- 8: End! -------'));

    self.spawnCommand('npm dedupe').on('exit', function(){
        self.spawnCommand('npm shrinkwrap').on('exit', function(){
            self.log();
            self.log(clc.green('!') + clc.whiteBright(' Successfully created ') + clc.cyan(self.appTitle));
            self.log(clc.green('!') + clc.whiteBright(' To see your site, run:'));
            self.log('\t' + clc.yellowBright('grunt serve'));
            self.log();
            done();
            self.log(msgStepEnd('------- 8: The End! -------'));
        });
    });  
}
此组合将导致在主版本和依赖级别上使用固定版本进行重复数据消除安装

这还将使jsphantom安装保持在主级别,而不是作为一个依赖项,以避免讨论的错误。因此,当您下载了一个版本化的项目,但没有使用node_modules文件夹时,将使用以下方法进行干净的安装:

$ npm install

这已经影响到我在grunt上的表现。因为grunt mocha在Ubuntu上没有同样的问题似乎无法工作。npm版本是1.4.9。通过使用这个定制路径npm安装,它工作得非常好。这个问题现在已经在phantomjs npm包中修复了。