【问题标题】:Yeoman generator always get some errorYeoman 生成器总是出错
【发布时间】:2014-05-23 07:24:20
【问题描述】:

当我尝试使用 yeoman web 生成器时,虽然它可以工作,但是查看整个生成进度,它总是在下面给我一些错误,无论我使用什么生成器,它们总是在那里。

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 项目完全没有影响?

【问题讨论】:

  • 它已经在 grunt 上影响了我。因为 grunt-mocha 似乎没有这些就无法工作
  • 在 Ubuntu 上遇到同样的问题。 npm 版本是 1.4.9。否则是完全相同的问题。

标签: phantomjs yeoman yeoman-generator


【解决方案1】:

Bitbucket CDN 目前似乎有问题。

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

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

【讨论】:

【解决方案2】:

提到的解决方法是:

您可以在此处手动下载 phantomjs zip:https://bitbucket.org/ariya/phantomjs/downloads 并将其移动到 npm 想要下载的目录。

下载 http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-macosx.zip 保存到 /var/folders/fl/ssqg11_j1hs5mk4fvyqgjcmc0000gn/T/phantomjs/phantomjs-1.9.7-macosx.zip . .

每当您下次尝试构建项目时,phantomjs 已经存在并且不必下载,因此将跳过下载并且您的项目将完成(除非遇到另一个错误)。

【讨论】:

    【解决方案3】:

    我有同样的问题,我遇到了这个帖子,有人声称他找到了类似问题的解决方法:https://github.com/Medium/phantomjs/issues/161

    “同样,通过从https://bitbucket.org/ariya/phantomjs/downloads 下载到它尝试将其保存到的路径使其正常工作。bitbucket repo 最近是否在私有/公共之间切换?”

    看起来 phantomjs 下载不再有效(或类似);许多人同时遇到相同问题的事实表明情况可能就是这样。

    我知道的不够多,无法建议您如何继续,但也许这可以为您指明正确的方向。

    【讨论】:

      【解决方案4】:

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

      • Windows 7 x64
      • 节点 v0.10.32
      • npm v2.5.0
      • 约曼 v1.3.2
      • grunt-cli v0.1.13
      • grunt-html-snap v0.6.1(grunt-html-snapshots 有同样的问题)
      • grunt-lib-phantomjs v0.3.0(依赖于 grunt-html-snap(s))
      • phantomjs v1.9.15(依赖于 grunt-lib-phantomjs(s))

      不太重要:

      • 凉亭 v1.3.12
      • git v1.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
      

      起初我以为我通过在 github HERE 上发布的修复程序解决了这个问题。在此 github issue post 上,您还可以找到其他可能的解决方案。

      但是当我几周后尝试生成一个新项目时,我遇到了同样的问题......

      我的生成器执行以下安装命令:

      install: function () {
          var self = this,
              done = self.async();
          self.log(msgStepStart('------- 7: Installing! -------'));
      
          // ---------- Generate STRUCTURE : Installation of npm packages START ---------- //
          self.npmInstall([
              'grunt@0.4.5',
              'grunt-contrib-clean@0.6.0',
              'grunt-contrib-concat@0.5.0',
              'grunt-contrib-connect@0.9.0',
              'grunt-contrib-copy@0.7.0',
              'grunt-contrib-cssmin@0.11.0',
              'grunt-contrib-htmlmin@0.3.0',
              'grunt-contrib-jshint@0.10.0',
              'grunt-contrib-less@1.0.0',
              'grunt-contrib-uglify@0.7.0',
              'grunt-contrib-watch@0.6.1',
              'grunt-html-snapshot@0.6.1',
              'grunt-rev@0.1.0',
              'grunt-text-replace@0.4.0',
              'grunt-usemin@3.0.0',
              'jit-grunt@0.9.0',
              'jshint-stylish@1.0.0',
              'load-grunt-tasks@2.0.0',
              'lodash@2.4.1',
              'request@2.42.0', // Dependancy: grunt-html-snapshot@0.6.1
              'time-grunt@1.0.0'
          ], { 'save': true, 'saveExact': true }, function() {
              done();
              self.log(msgStepEnd('------- 7: I am done installing! -------'));
          });
      
          // npm save as save, saveDev or saveExact?
          // --save: Package will appear in your dependencies.
          // --save-dev: Package will appear in your devDependencies.
          // --save-optional: Package will appear in your optionalDependencies.
      
          // When using any of the above options to save dependencies to your package.json, there is an additional, optional flag:
          // --save-exact: Saved dependencies will be configured with an exact version rather than using npm's default semver range operator. 
          // --save-dev-exact would be the sam as | { 'saveDev': true } => { 'saveDevExact': true }
      
          // ---------- Generate STRUCTURE : Installation of npm packages END ---------- //
      
      }
      

      我也尝试了phantomjs troubleshooting,但都没有解决我的问题。

      然后,当我尝试使用 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
      

      当我使用 grunt-html-snapshot 执行此操作时,10 次中有 10 次出现相同的错误。

      $ npm install grunt-html-snapshot
      OR
      $ npm install grunt-html-snapshot@0.6.1
      

      这让我开始思考。我在一个新文件夹上安装了带有 npm 的 phantomjs 并运行了我的生成器。这导致安装没有错误 10 次中的 10 次。

      为了让生成器处理完整的安装,我在生成器的冲突方法优先级下添加了 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! -------'));
          });
      },
      

      这完全解决了我的问题,希望对其他人有所帮助。

      附:

      如果您使用任何类型的版本控制来为已部署的项目遗漏已安装的 node_modules。您可以考虑在生成器的结束方法优先级中使用以下内容。

      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
      

      【讨论】:

        猜你喜欢
        • 2016-06-14
        • 1970-01-01
        • 1970-01-01
        • 2014-05-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-18
        • 1970-01-01
        相关资源
        最近更新 更多