可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
When running npm install [any package]
or even npm install
on homestead I get the following error:
npm ERR! ETXTBSY: text file is busy, rmdir '/home/vagrant/valemus-shop-starter/valemus-shop/node_modules/fsevents'
Debug log can be seen here
- Box 'laravel/homestead' (v3.0.0)
- Node: v8.2.1
- NPM: 5.3.0
I tried removing the fsevents
directory, however, it doesn't exist.
How do I fix this?
回答1:
Just issue "npm install" in Windows instead of in Homestead. Of course, you need to have npm for windows installed to do that.
回答2:
I ran into the same thing on Windows 10 + VirtualBox (VBox) + Vagrant + Laravel Homestead when I wanted to change to react frontend.
And after much search and trial and error, this solution worked for me, maybe it works for you as well.
Halted the vagrant:
vagrant halt
Added the following into the configure section of the Vagrantfile in the Homestead dir
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
started the cmd as admin
then vagrant up
and vagrant ssh
cd to development dir
then removed the node_modules dir by rm -rf node_modules/
if any
and then ran the sudo npm install && npm run dev
and the whole thing was installed without any warnings or errors.
This is the result of two hours reading :)
Edit:
If your problem is not solved and you have the mentioned setup you can use another solution:
Install the Node on your windows machine too
Then cd to your development directory and run the npm install
from the Windows and the you'll have the same result.
You can also initiate the npm run watch
from a windows cmd afterwards.
This helped me to lift the load from the VM and let the Windows do the watch and receive the notifications of the npm run watch
in Windows.
Cheers
回答3:
The same thing happened to me
My environment is linux
fsevents is a module dedicated to mac
Please try the following command
npm install --no-optional
回答4:
I struggled with this problem on my Windows 10 machine with Homestead a lot of. And After a lot of effort I solved it with that way;
delete your node_modules folder.
You run this commands on your windows terminal:
npm install --no-bin-links (After some experience it is necessary for virtual machines)
npm rebuild --no-bin links
Generally it works after these commands, but if you have take this error
"Node Sass could not find a binding for your current environment:"
please run this command on your Homestead Terminal for installing node Sass for Linux.
npm rebuild node-sass
if it is not work, try use yarn. Delete node modules folder package.json.lock and yarn.lock (if there) files and type
yarn install
If all of them is not save you, use all npm commands out of the virtual machine. It will be work.
I hope this helps you...
回答5:
Downgraing the npm version to 5.7.1 did the trick for me.
Command used to downgrade: npm install -g npm@5.7.1
I am using Win10, Vagrant, Ubuntu v14.04 and Node v8.11.4
回答6:
I had problem with "npm install" too, I use Windows 10. Finally I got it fixed, what I did is that I exited from "vagrant ssh" and run "vagrant box update", then "npm install" worked. Notice that I ran "vagrant box update" and "npm install" out of "vagrant ssh". Hope it helps.
回答7:
I was still getting an error, even after doing following
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id,
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
as suggested by Babak Bandpey
It turned out that there was another annoying problem of file path character limit. This happens quite often if you are using a node module with long name. You can easily solve this by following these steps after vagrant ssh into linux vm:
- Create ‘node_modules’ folder in your home folder
mkdir ~/node_modules
Add symbolic link to the ‘node_modules’ folder you just created inside your project folder
ln -sf ~/node_modules /vagrant/your-project-folder
This solution will ensure that all the node modules are stored inside home directory instead of synced folder. Original source : https://blog.rudylee.com/2014/10/27/symbolic-links-with-vagrant-windows/
Hope it helps somone having similar issue, thanks!
回答8:
I also struggle finding a solution for this but here it is.
- Make sure to update node to latest version
To update, you can install n
sudo npm install -g n
Then just :
sudo n latest
- Set Node scripts to use environment variables across platforms
In vagrant run :
npm install --save-dev cross-env
npm install
npm run dev
That did the trick , although i spent an entire day finding the right solution (https://www.npmjs.com/package/cross-env)
回答9:
i had to delete the node_modules folder first, then i did
sudo chmod a+x .
for making sure i got the privilege to do anything on the machine, then i
sudo npm install --no-bin-links
no bin links is required in vagrant from my experience because these VM don't support bin links (correct me if im wrong). Then i just
sudo npm run dev
at this point some people might encounter no cross-env found error. In that case, just delete cross-env in package.json file and run it again. It worked for me but some people still encounter the same problem. Might worth to give it a shot.