Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save atomtigerzoo/ce6edb3f778f18d0cce2 to your computer and use it in GitHub Desktop.
Save atomtigerzoo/ce6edb3f778f18d0cce2 to your computer and use it in GitHub Desktop.
Virtualbox on Windows 7/Windows 10: Use npm/nodejs within a shared folder

Do not create a shared folder in settings/before - it will be created in step 3!

Enable symlinks for your VM

Open Windows PowerShell with adminstrator rights, enter:

$ VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

Check if it got set:

$ VBoxManage getextradata YOURVMNAME enumerate

Add a new shared folder to your VM

Inside the same PowerShell with administrator rights enter:

$ VBoxManage sharedfolder add YOURVMNAME --name "YOURSHAREFOLDERNAME" --hostpath "\\?\C:\PATH\TO\YOUR\SHARED\FOLDER\ON\WINDOWS"

Start VirtualBox (or your headless VM) as Adminstrator

Auto-mount the new shared folder (On the VM console/terminal)

Create a new folder for the mount:

$ mkdir /PATH/TO/NEW/FOLDER

Open:

$ sudo nano /etc/rc.local

Inside the file before the exit 0 enter:

 # Mount shared folder
 /sbin/mount.vboxsf YOURSHAREFOLDERNAME /PATH/TO/NEW/FOLDER vboxsf

Save and reboot your VM.

Troubleshooting

Sometimes, after a new version of VirtualBox or debian updates, you need to reinstall the GuestAdditions and run sudo m-a prepare and sudo apt-get install build-essential linux-headers-uname -r dkms to install the new linux headers that somehow get lost sometimes...

@pedrosfdcarneiro
Copy link

Thank you for the gist. It worked for me!

If anyone wants to make use of the hot reload feature of webpack-dev-server, the poll method should be used in the webpack watch options: https://webpack.js.org/configuration/watch/#watchoptionspoll, otherwise the default method won't work in this scenario.

@atomtigerzoo
Copy link
Author

You're welcome - good to know that it helped & worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment