By soulgalore
I setup my server using Vagrant (Ubuntu 14 64 bit), I install my packages using two shell scripts. One installs all the packages needed and the other one install packages using npm and is set to privileged: false. It looks like this:
config.vm.provision :shell, :path => "setup-nodejs.sh", privileged: false
When I run my Vagrant box on my local, it works fine, all packages is installed and the packages using npm.
But when I run it deploying to digital ocean, it fails with node: Permission denied. I guess it happens because the user that tries to install via npm is root and that doesn’t work for npm (if I install it manually, I need to create another user to run and install using npm).
What is the best way to setup your Vagrant file to install node and then run npm so it works on Ubuntu?
The Vagrant file I’m using is (not including the digital ocean info): https://github.com/sitespeedio/sitespeed.io-vagrant/tree/master/sitespeed-ubuntu14
Best Peter
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Looking at an older revision of your repo, it looks like you need to add the --unsafe-perm flag to the npm install commands. From the npm config docs:
unsafe-perm
- Default: false if running as root, true otherwise
- Type: Boolean Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.