By vianettim
Hello. I’m evaluating the app platform to see if we can migrate our Ruby on Rails app to here from Heroku. I tried adding npm install as a build command, and I can see it output in the logs while building the app, but it doesn’t appear to be succeeding as we’re getting an error while precompiling assets. The missing asset is one that gets installed via npm. So, my question is: what is the “correct way” to do an npm install before a Rails app precompiles assets? Do I need to add commands to install nodejs and npm (I’ve tried this to no avail)? Thanks
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!
I had the same issue and the same hypothesis. Upon further inspection, I noticed a tiny little error in the log.
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
That’ll do it! I tried running yarn install --frozen-lockfile locally and, indeed, it failed. The digital ocean buildpack appears to continue building if that fails, though, and goes on to run rake assets:precompile.
The solution was to run yarn install locally, which updated yarn.lock, then redeploy.
The ruby/rails buildpack will automatically install node modules and run assets:precompile as part of the build process. Currently npm isn’t available by default in that image, just yarn for now, which we’re tracking internally and plan to address. In the meantime, if you need to interact with node, you should use yarn instead of npm.
Alternatively, if you need a more flexible or customized environment, you can build with a Dockerfile.
Thanks for using the App Platform — happy coding!
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.