sandstorm-io / vagrant-spk

Packaging tool for Sandstorm, a self-hosting platform for web apps!
Apache License 2.0
55 stars 29 forks source link

npm install largely does not work within Vagrant #320

Open orblivion opened 2 years ago

orblivion commented 2 years ago

When I try to build an app that uses npm install with vagrant-spk, certain node packages have assorted errors of expected files missing during the build process. If I ssh into the VM to inspect the situation, I find that the containing directories are often not there either.

I poked around the Internet and it seems to be a known issue with VirtualBox and npm:

I'm not sure I get the complete picture of what's going on. Supposedly this is due to VirtualBox disabling symlinks for synced folders for security reasons. From direct observation I can ssh into my VM and create a symlink, so I'm not sure exactly what's going on. But my npm is in fact failing.

Proposed Workarounds

Turn symlinks back on with a setting

You can turn the symlinks back on with a setting if you trust the guest VM. I tried it once and it didn't work. I likely did it wrong.

Bind Mount (worked for me)

You can apparently work around this with a bind mount:

Now, I'm not sure if I'm getting this suggestion right, but it worked for me in the following way:

At this point it will run. If there's a problem with symlinks, I'm not sure why it does, given that it can't build. I even tried comparing the node_modules directories in /opt/app and /opt/build/app/ and they're the same.

Other

There are others. One was to use NFS to sync them, not sure how secure that is in this context.

Assorted: