🇻 Using NPM with Vagrant
Using a Vagrant Ubuntu backend on a Windows 10 is my current preferred development environment, but unfortunately the folder syncing process causes a lot of issues. A recent project I’m doing involves a lot of JS, and npm
in particular caused quite a few headaches. This is a list of stuff I had to do in order for it to work:
- Polling: See https://github.com/facebook/create-react-app/issues/1049 -
CHOKIDAR_USEPOLLING=true npm start
is needed for autorestarting the react server. - If permissions errors occur, change (from Windows) the Attributes of the shared folder and deselect “Read-only”.
- Issues with symlinks. Resolved per https://github.com/npm/npm/issues/992:
- On the host machine (assuming Windows), but some variation of this will work in any OS:
cd C:\Program Files\Oracle\VirtualBox
- Run the following command:
VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1
, replacingVM_NAME
with your Virtual Machine’s name (if you don’t know this, in VBox go toMachine > Settings > General > Basic > Name
— also replace SHARE_NAME with the name of your shared folder, if you don’t remember this, go to Machine > Settings > Shared Folders. - Restart your VM AND VirtualBox, but run it as administrator. On Windows hosts, just right click the icon for VirtualBox and select Run as Administrator.
- Also see: https://stackoverflow.com/questions/23936458/correct-way-to-setup-virtualbox-4-3-to-use-symlinks-on-guest-for-meteor
- On the host machine (assuming Windows), but some variation of this will work in any OS:
- Other issues with Windows: Disable antivirus/firewall per https://github.com/react-community/create-react-native-app/issues/191
Notes:
- RSync is one way, useless.
npm
is generally weird to use on shared folders, most of which is due to symlinks.- Windows Linux subsystem is useless, you can’t edit stuff from Windows.