laravel vagrant/homestead/windows 上的 npm 安装错误:EPROTO:协议错误,符号链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33186123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install errors on vagrant/homestead/windows: EPROTO: protocol error, symlink
提问by Diane Kaplan
I'm building my first project in Laravel and trying to use Elixir, using homestead on Windows 8.1. I've hit the known npm/vagrant issue of too-long-path-names: https://harvsworld.com/2015/how-to-fix-npm-install-errors-on-vagrant-on-windows-because-the-paths-are-too-long/
我正在 Laravel 中构建我的第一个项目并尝试使用 Elixir,在 Windows 8.1 上使用 homestead。我遇到了太长路径名的已知 npm/vagrant 问题:https: //harvsworld.com/2015/how-to-fix-npm-install-errors-on-vagrant-on-windows-because -路径太长/
So I made the one line edit recommended in that article (thank god for that guy), and then ran (with and without sudo): npm install --no-bin-links
所以我做了那篇文章中推荐的单行编辑(感谢那家伙),然后运行(有和没有 sudo): npm install --no-bin-links
It's moved me ahead so now I get two different kinds of errors: some 'Missing write access' errors, and a bunch of "EACCES" errors:
它让我前进,所以现在我收到两种不同类型的错误:一些“缺少写入访问”错误和一堆“EACCES”错误:
The error output gives me my next clue in the scavenger hunt (I think): Please try running this command again as root/Administrator
错误输出为我提供了寻宝游戏中的下一个线索(我认为):请尝试以 root/管理员身份再次运行此命令
That brings me to this post, but the difference for me is there's no change even after I use sudo (or update my user permissions like so):
这让我看到了这篇文章,但对我来说不同的是,即使在我使用 sudo(或像这样更新我的用户权限)之后也没有任何变化:
sudo chown -R $USER /usr/local
须藤 chown -R $USER /usr/local
sudo chown -R $(whoami) ~/.npm
须藤 chown -R $(whoami) ~/.npm
Update: then after the suggestion belowI get EPROTO and EXTXTBSY errors (even after following the prompted suggestion to rename the npm-debug.log back:
更新:然后在下面的建议之后,我收到 EPROTO 和 EXTXTBSY 错误(即使按照提示的建议将 npm-debug.log 重命名回来:
So I tried running gulp to see if it would give me clues, and error output had me do:
所以我试着运行 gulp 看看它是否会给我线索,错误输出让我做:
sudo npm rebuild node-sass
Running that gives me the same EPROTO and ETXTBSY errors, and the npm-debug.log file shows: error EPROTO: protocol error, symlink '../node-sass/bin/node-sass' -> '/home/vagrant/Code/Family-laravel/node_modules/laravel-elixir/node_modules/gulp-sass/node_modules/.bin/node-sass'
运行它会给我相同的 EPROTO 和 ETXTBSY 错误,并且 npm-debug.log 文件显示:错误 EPROTO:协议错误,符号链接 '../node-sass/bin/node-sass' -> '/home/vagrant/代码/Family-laravel/node_modules/laravel-elixir/node_modules/gulp-sass/node_modules/.bin/node-sass'
Then after working on some other stuff for an hour I came back fresh and redid these steps, this time getting way fewer errors:
然后在处理其他一些事情一个小时后,我重新回来并重新执行了这些步骤,这次错误更少:
sudo npm -g install npm@latest (fine)
sudo npm install --no-bin-links (just the ETXTBSY error and an error in plugin 'run sequence', in task 'sass')
sudo npm rebuild node-sass --no-bin-links (no errors!)
gulp (just one error: not found: notify-send)
sudo npm -g install npm@latest(很好)
sudo npm install --no-bin-links(只是 ETXTBSY 错误和插件“运行序列”中的错误,在任务“sass”中)
sudo npm rebuild node-sass --no-bin-links(没有错误!)
吞咽(只有一个错误:未找到:通知发送)
Getting closer!
越来越近!
回答by Adam
I have been trying to figure out this problem for weeks. Here is what I did to make it work without using my host environment:
几个星期以来,我一直试图找出这个问题。这是我在不使用主机环境的情况下使其工作的方法:
I updated node to the latest version in homestead according to nodesource.com:
我根据 nodesource.com 将 node 更新到 homestead 中的最新版本:
sudo apt-get install --yes nodejs
curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
I updated npm to the latest version in homestead. This should be done after updating node:
我在 homestead 更新了 npm 到最新版本。这应该在更新节点后完成:
sudo npm -g install npm@latest
I ran npm install in the laravel project directory. I also had to use force to get all of the dependencies to install:
我在 Laravel 项目目录中运行了 npm install。我还必须使用 force 来安装所有依赖项:
sudo npm install --no-bin-links
sudo npm cache clear
sudo npm install --force --no-bin-links
I rebuilt node-sass according to a gulp error:
我根据 gulp 错误重建了 node-sass:
sudo npm rebuild node-sass --no-bin-links
During this whole process if something fails or after each install, i used:
在整个过程中,如果出现故障或每次安装后,我使用:
sudo npm cache clear
My host is windows 10, with latest virtualbox, latest vagrant, latest homestead. I used git bash as administrator and ssh into vagrant using git bash.
我的主机是 Windows 10,具有最新的虚拟机、最新的流浪者、最新的宅基地。我以管理员身份使用 git bash 并使用 git bash ssh 进入 vagrant。
So far I have only tested and confirmed that my gulp works. It is possible that other dependencies need to be rebuilt.
到目前为止,我只测试并确认我的 gulp 有效。可能需要重新构建其他依赖项。
Hope this helps!
希望这可以帮助!
回答by Daniel Camargo
As many of you that are also setting up Homestead with Virtual Box...
正如你们中的许多人也在用Virtual Box设置 Homestead ......
After googling for a solution I decided to refer back to the Laravel Homesteaddocumentation. Fortunately the solution was posted there:
在谷歌搜索解决方案后,我决定参考Laravel Homestead文档。幸运的是,解决方案已发布在那里:
https://laravel.com/docs/5.8/homestead#provider-specific-settings
https://laravel.com/docs/5.8/homestead#provider-specific-settings
You just need to add the following to your homestead Vagrantfile.
您只需要将以下内容添加到您的 homestead Vagrantfile 中。
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
(...)
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
(...)
end
IMPORTANT
重要的
Don't forget to provision as an administrator.
不要忘记以管理员身份进行配置。
homestead up --provision
homestead up --provision
回答by Rich Remer
The cause of your initial EACCES
error was that you used sudo
without using the -H
option. NEVER use sudo npm
. ALWAYS use sudo -H npm
.
初始EACCES
错误的原因是您在sudo
未使用该-H
选项的情况下使用了该选项。永远不要使用sudo npm
. 始终使用sudo -H npm
.
The instructions on the Internet everywhere (including NPM docs) are simply wrong.
网上到处的说明(包括 NPM 文档)都是错误的。
回答by Thavaprakash Swaminathan
I had same problem. I did below. It works fine.
我有同样的问题。我在下面做的。它工作正常。
npm install --no-bin-links
回答by Baljeet Bhinder
I solved my issue with the solution described here: https://www.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/
我用这里描述的解决方案解决了我的问题:https: //www.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/
The main trick was in:
主要技巧在于:
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/path/to/guest/shared/directory", "1"]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/path/to/guest/shared/directory", "1"]
Hope it helps someone
希望它可以帮助某人