Question

Functions on App Platform: `npm: Command not found` during remote build

I have a node.js function set up, which works fine using the CLI to deploy to a development workspace. Now I’m trying to deploy it as part of an app. I push the code to GitHub and the build is triggered, but I get this:

[2023-03-09 16:39:12] ╭──────────── git repo clone ───────────╼
[2023-03-09 16:39:12] │  › fetching app source code
[2023-03-09 16:39:12] │ => Selecting branch "deploy"
[2023-03-09 16:39:13] │ => Checking out commit "c670dcbcdada6094f6bd002a0e5c7c3f1ab7139a"
[2023-03-09 16:39:13] │ 
[2023-03-09 16:39:13] │  ✔ cloned repo to /.app_platform_workspace
[2023-03-09 16:39:13] ╰────────────────────────────────────────╼
[2023-03-09 16:39:13] 
[2023-03-09 16:39:13]  › applying source directory functions
[2023-03-09 16:39:13]  ✔ using workspace root /.app_platform_workspace/functions
[2023-03-09 16:39:13] 
[2023-03-09 16:39:16]  › validating project.yml configuration
[2023-03-09 16:39:17]  ✔ project.yml is valid
[2023-03-09 16:39:17]  › preparing build environment
[2023-03-09 16:39:18] 
[2023-03-09 16:39:18] ╭──────────── project build ───────────╼
[2023-03-09 16:39:19] │ Started running npm install && npm run build in /.app_platform_workspace/functions/lib
[2023-03-09 16:39:19] │ /bin/bash: line 1: npm: command not found
[2023-03-09 16:39:19] │ 
[2023-03-09 16:39:19] │  ›   Error: 'npm install' exited with code 127
[2023-03-09 16:39:19] │ 
[2023-03-09 16:39:19] │ command exited with code 1
[2023-03-09 16:39:19] │ 
[2023-03-09 16:39:20] │  ✘ build failed

The remote build process seems unable to find its own npm binary. Any advice will be gratefully received.


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
March 10, 2023

Hi there,

This is quite interesting, do you have your package.json file committed to your GitHub repository?

I’ve just tested this out with the following sample Node.js function and it seems to be picking up the Node and npm binaries as exepcted:

https://github.com/digitalocean/sample-functions-nodejs-qrcode

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up