Error in NPM installing express via package.json

2019-05-22 17:04发布

问题:

My node and npm versions are recent. But getting error and no express folder is coming up under ./node_modules. Express folder is coming up under /home/vagrant/.npm npm-debug.log is generated. Not sure how to attach that.

npm ERR! Linux 3.13.0-68-generic
npm ERR! argv "/home/vagrant/.nvm/versions/node/v4.2.2/bin/node" "/home/vagrant/.nvm/versions/node/v4.2.2/bin/npm" "install"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! path ../mime/cli.js
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink

npm ERR! EPROTO: protocol error, symlink '../mime/cli.js' -> '/vagrant/testProject/node_modules/express/node_modules/send/node_modules/.bin/mime'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Linux 3.13.0-68-generic
npm ERR! argv "/home/vagrant/.nvm/versions/node/v4.2.2/bin/node" "/home/vagrant/.nvm/versions/node/v4.2.2/bin/npm" "install"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! path npm-debug.log.f7bc0249588f17bea044ac621dd74bb9
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename

回答1:

You need to run npm with -–no-bin-link option to tell npm that your filesystem doesn't support links

If you want to do the --no-bin-link on each npm command, you can add an alias to your .bashrc file in your home directory with this command:

echo "alias npm='npm --no-bin-links'" >> /home/vagrant/.bashrc

Another possibility is to set your configuration to allow symlinks on Windows hosts in your Vagrantfile

config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
end

see https://github.com/npm/npm/issues/7308 for more detail



回答2:

You should tell npm that your file system doesn't support symbolic links, e.g.

npm config set bin-links false

Source: npm doesn't work in vagrant at GH-7308