NPM通过package.json安装Express时出错

NPM通过package.json安装Express时出错

问题描述:

我的节点和npm版本是最新的.但是在./node_modules下出现错误并且没有快速文件夹.Express文件夹位于/home/vagrant/.npm下生成npm-debug.log.不确定如何附加.

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

您需要使用-no-bin-link 选项运行npm,以告诉npm您的文件系统不支持链接

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

如果要在每个npm命令上执行-no-bin-link ,则可以使用以下命令将别名添加到主目录中的 .bashrc 文件中:该命令:

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

另一种可能性是将您的配置设置为允许Vagrantfile中Windows主机上的符号链接

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

请参见 https://github.com/npm/npm/issues/7308 了解更多详情