ENOENT erros ao executar npm dentro da provisão de shell do vagrant

1
  1. Tenha um projeto com o seguinte arquivo package.json :

    {
        "name": "requirejs-library-skeleton",
        "description": "RequireJS skeleton for modern JS libraries.",
        "version": "0.2.0",
        "homepage": "http://github.com/tkellen/requirejs-library-skeleton",
        "author": "Tyler Kellen",
        "engines": {
            "node": ">=0.6.0"
        },
        "scripts": {
            "test": "grunt test"
        },
        "devDependencies": {
            "grunt": "~0.4",
            "grunt-contrib-watch": "*",
            "grunt-contrib-less": "~0.6.1",
            "grunt-contrib-requirejs": "~0.3.2",
            "grunt-contrib-jasmine": "~0.4.0",
            "grunt-template-jasmine-requirejs": "*",
            "grunt-contrib-connect": "~0.1.0",
            "grunt-file-creator": "*",
            "clean-pattern": "*",
            "grunt-concat-css": "*",
    
            "grunt-phpcs": "*",
            "grunt-phplint": "*",
            "grunt-phpunit": "*",
            "grunt-exec": "*"
        }
    }
    
  2. Tenha o seguinte Vagrantfile config:

    Vagrant.configure("2") do |config|
    
      config.vm.box = "precise32"
      config.vm.box_url = "http://files.vagrantup.com/precise32.box"
    
      config.vm.provision :shell, :path => "bootstrap/bootstrap.sh"
    
    # ... other stuff like opening ports ...
    
    end
    
  3. bootstrap.sh é o mais interessante e se parece com isso:

    #!/usr/bin/env bash
    
    # Installing prequisites for adding nodejs repository
    apt-get update
    apt-get install -y python-software-properties python g++ make
    
    # Adding Nodejs specific repository
    add-apt-repository -y ppa:chris-lea/node.js
    
    # Installing other software
    # ... apt-get invocations ...
    
    # Installing grunt harness
    npm install -g grunt-cli
    
    # Other preparation tasks
    # ... setting up DB, runtime directories, generating configs, etc.
    
    # Moving to codebase root now
    cd /vagrant
    
    # Disguising ourselves as normal user (hack 1)
    su vagrant
    
    # Cleaning the NPM cache (hack 2)
    npm cache clean
    
    # Installing nodejs prequisites
    npm install
    
    # Rebuilding codebase (I have to run it after EVERY change in configuration, CSS and/or JS files).
    grunt
    
    # Other post-deploy application-specific things
    # ...
    
    echo "All should be done\n";
    
  4. Na invocação de npm install , ela falha miseravelmente com os seguintes erros aleatórios:

    npm http GET https://registry.npmjs.org/lodash/-/lodash-1.0.1.tgz                                                                                                         
    npm ERR! Error: ENOENT, lstat '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/adm-zip/.travis.yml'      
    npm ERR! If you need help, you may report this log at:                                                                                                                    
    npm ERR!     <http://github.com/isaacs/npm/issues>                                                                                                                        
    npm ERR! or email it to:                                                                                                                                                  
    npm ERR!     <[email protected]>                                                                                                                                      
    
    npm ERR! System Linux 3.2.0-23-generic-pae                                                                                                                                
    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"                                                                                                                 
    npm ERR! cwd /vagrant                                                                                                                                                     
    npm ERR! node -v v0.10.22                                                                                                                                                 
    npm ERR! npm -v 1.3.14                                                                                                                                                    
    npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/adm-zip/.travis.yml                        
    npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/adm-zip/.travis.yml                
    npm ERR! fstream_type File                                                                                                                                                
    npm ERR! fstream_class FileWriter                                                                                                                                         
    npm ERR! code ENOENT                                                                                                                                                      
    npm ERR! errno 34                                                                                                                                                         
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26                                                                                
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)                                                                                                                   
    npm ERR! Error: ENOENT, lstat '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/mkdirp/test/mkdirp.js'    
    npm ERR! If you need help, you may report this log at:                                                                                                                    
    npm ERR!     <http://github.com/isaacs/npm/issues>                                                                                                                        
    npm ERR! or email it to:                                                                                                                                                  
    npm ERR!     <[email protected]>                                                                                                                                      
    
    npm ERR! System Linux 3.2.0-23-generic-pae                                                                                                                                
    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"                                                                                                                 
    npm ERR! cwd /vagrant                                                                                                                                                     
    npm ERR! node -v v0.10.22                                                                                                                                                 
    npm ERR! npm -v 1.3.14                                                                                                                                                    
    npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/mkdirp/test/mkdirp.js                      
    npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/mkdirp/test/mkdirp.js              
    npm ERR! fstream_type File                                                                                                                                                
    npm ERR! fstream_class FileWriter                                                                                                                                         
    npm ERR! code ENOENT                                                                                                                                                      
    npm ERR! errno 34                                                                                                                                                         
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26                                                                                
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)                                                                                                                   
    npm ERR! EEXIST, mkdir '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test'                    
    File exists: /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test                                
    Move it away, and try again.                                                                                                                                              
    
    npm ERR! System Linux 3.2.0-23-generic-pae                                                                                                                                
    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"                                                                                                                 
    npm ERR! cwd /vagrant                                                                                                                                                     
    npm ERR! node -v v0.10.22                                                                                                                                                 
    npm ERR! npm -v 1.3.14                                                                                                                                                    
    npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test                               
    npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/npmconf/test/builtin.js            
    npm ERR! fstream_type File                                                                                                                                                
    npm ERR! fstream_class FileWriter                                                                                                                                         
    npm ERR! code EEXIST                                                                                                                                                      
    npm ERR! errno 47                                                                                                                                                         
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23                                                                                
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53                                                                                       
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)                                                                                                                   
    npm ERR! Error: ENOENT, lstat '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/kew/test/context.js'      
    npm ERR! If you need help, you may report this log at:                                                                                                                    
    npm ERR!     <http://github.com/isaacs/npm/issues>                                                                                                                        
    npm ERR! or email it to:                                                                                                                                                  
    npm ERR!     <[email protected]>                                                                                                                                      
    
    npm ERR! System Linux 3.2.0-23-generic-pae                                                                                                                                
    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"                                                                                                                 
    npm ERR! cwd /vagrant                                                                                                                                                     
    npm ERR! node -v v0.10.22                                                                                                                                                 
    npm ERR! npm -v 1.3.14                                                                                                                                                    
    npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/kew/test/context.js                        
    npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/kew/test/context.js                
    npm ERR! fstream_type File                                                                                                                                                
    npm ERR! fstream_class FileWriter                                                                                                                                         
    npm ERR! code ENOENT                                                                                                                                                      
    npm ERR! errno 34                                                                                                                                                         
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26                                                                                
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)                                                                                                                   
    npm ERR! EEXIST, mkdir '/vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src'           
    File exists: /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src                       
    Move it away, and try again.                                                                                                                                              
    
    npm ERR! System Linux 3.2.0-23-generic-pae                                                                                                                                
    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"                                                                                                                 
    npm ERR! cwd /vagrant                                                                                                                                                     
    npm ERR! node -v v0.10.22                                                                                                                                                 
    npm ERR! npm -v 1.3.14                                                                                                                                                    
    npm ERR! path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src                      
    npm ERR! fstream_path /vagrant/node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/ncp/test/fixtures/src/d            
    npm ERR! fstream_type File                                                                                                                                                
    npm ERR! fstream_class FileWriter                                                                                                                                         
    npm ERR! code EEXIST                                                                                                                                                      
    npm ERR! errno 47                                                                                                                                                         
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23                                                                                
    npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53                                                                                       
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)  
    

O que diabos está acontecendo aqui?

Se eu executar o vagrant ssh e executar cd /vagrant; npm install , o npm será executado sem problemas!

    
por hijarian 18.11.2013 / 15:51

1 resposta

2

Ok, eu encontrei a solução aqui: link

Eu só tenho que usar npm install --no-bin-links . Ficaria feliz em ter uma resposta por que .

    
por 18.11.2013 / 20:15

Tags