You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Now, I'm not sure if I'm getting this suggestion right, but it worked for me in the following way:
In setup.sh:
create /opt/build
In build.sh:
copy /opt/app to /opt/build/app
sudo mount --bind /opt/build/app /opt/app
at this point /apt/app is not synced to your host, but npm will build thinking it's sitting in /opt/app.
do build as normal within /opt/app
this of course actually builds in /opt/build/app, but if your generated files ever include an absolute path (as npm packages have) they will show up as /opt/app.
sudo umount /opt/app
copy node_modules and other generated directories from /opt/build/app to their respective places in /opt/app
Now the built node modules are inside the synced folder, and should show up in your host
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.
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:
setup.sh
:/opt/build
build.sh
:/opt/app
to/opt/build/app
sudo mount --bind /opt/build/app /opt/app
/apt/app
is not synced to your host, but npm will build thinking it's sitting in/opt/app
./opt/app
/opt/build/app
, but if your generated files ever include an absolute path (as npm packages have) they will show up as/opt/app
.sudo umount /opt/app
node_modules
and other generated directories from/opt/build/app
to their respective places in/opt/app
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:
The text was updated successfully, but these errors were encountered: