When using an Ubuntu VM on a Windows host, and developing on npm with a shared folder, you’re probably going to hit our “operation not permitted” error a lot. I installed browserify-rails on my rails app today, but i couldn’t compile my assets because of a series of issues with VirtualBox shared folders.
Here are the steps to get npm, rails, and virtualbox shared folders to play nice:
1. Run this in windows terminal as an administrator
`VBoxManage.exe setextradata YOUR_VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOUR_SHARED_FOLDER_NAME 1`
^ don’t forget the 1 at the end!
2. Run Virtualbox as an admin on Windows.
3. Go inside your project, and run `npm install`
4. move (via `mv`) the newly-created `node_modules` folder into a *native Linux folder*, e.g. `~/my-new-folder/node_modules`
5. Make a symlink from your project to the moved node_modules folder:
E.g. run this in your project: `ln -s ~/my-new-folder/node_modules .`
6. If you’re on Rails, do the same for the `tmp` folder as well.
`mv tmp ~/my-new-folder/tmp`
`ln -s ~/my-new-folder/tmp .`
7. (For Rails) run `assets:precompile`!
You can utilize .gitignore to ignore `node_module` and `tmp` symlinks if needed.
Post a Comment