Question

Node.js Deploy Build Error

I have a digital ocean app that connected with the.master branch, when I deploy to the server I have the below error, the error is appear suddenly. I have another app that connected with the same repo but for the branch staging, this work wells , and there is no build errors, both branches are same of the code.

─────────── app build ───────────╼
[2023-09-19 12:31:36] │ ---> Node.js Buildpack
[2023-09-19 12:31:36] │ ---> Installing toolbox
[2023-09-19 12:31:36] │ ---> - jq
[2023-09-19 12:31:37] │ ---> - yj
[2023-09-19 12:31:37] │ ---> Getting Node version
[2023-09-19 12:31:37] │ ---> Resolving Node version
[2023-09-19 12:31:39] │ ---> Downloading and extracting Node v16.20.2
[2023-09-19 12:31:43] │ ---> Parsing package.json
[2023-09-19 12:31:44] │ ---> No file to start server
[2023-09-19 12:31:44] │ ---> either use 'docker run' to start container or add index.js or server.js
[2023-09-19 12:31:44] │ Project contains package-lock.json, using npm
[2023-09-19 12:31:48] │ Using npm v8.19.4. To configure a different version of npm, set the engines.npm property in package.json.
[2023-09-19 12:31:48] │   See https://do.co/apps-buildpack-node for further instructions.
[2023-09-19 12:31:48] │ Installing node_modules using npm (from package-lock.json)
[2023-09-19 12:31:48] │ Running npm ci
[2023-09-19 12:31:48] │ 
[2023-09-19 12:32:12] │ npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
[2023-09-19 12:32:13] │ npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │ > project@1.0.0 prepare
[2023-09-19 12:32:25] │ > husky install
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │ sh: 1: husky: not found
[2023-09-19 12:32:25] │ npm notice 
[2023-09-19 12:32:25] │ npm notice New major version of npm available! 8.19.4 -> 10.1.0
[2023-09-19 12:32:25] │ npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.1.0>
[2023-09-19 12:32:25] │ npm notice Run `npm install -g npm@10.1.0` to update!
[2023-09-19 12:32:25] │ npm notice 
[2023-09-19 12:32:25] │ npm ERR! code 127
[2023-09-19 12:32:25] │ npm ERR! path /workspace
[2023-09-19 12:32:25] │ npm ERR! command failed
[2023-09-19 12:32:25] │ npm ERR! command sh -c -- husky install
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │ npm ERR! A complete log of this run can be found in:
[2023-09-19 12:32:25] │ npm ERR!     /home/apps/.npm/_logs/2023-09-19T12_31_48_953Z-debug-0.log
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │ unable to invoke layer creator
[2023-09-19 12:32:25] │ installing node_modules: exit status 127
[2023-09-19 12:32:25] │ ERROR: failed to build: exit status 1
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │ For documentation on the buildpacks used to build your app, please see:
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │    Node.js  v0.3.6  https://do.co/apps-buildpack-node
[2023-09-19 12:32:25] │ 
[2023-09-19 12:32:25] │  ✘ build failed
[]

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.

Hi there,

The build error you are facing is due to husky not being found when the prepare script is running:

[2023-09-19 12:32:25] │ sh: 1: husky: not found

I could suggest a few things to try:

  1. Make sure husky is listed as a dependency in your package.json file. If it’s missing, you need to add it:

    npm install husky --save-dev
    
  2. On your local environment, try deleting both the node_moduels directory and the package-lock-json file and the reinstall:

    rm -rf node_modules package-lock.json
    npm install
    

    After this, commit the changes and try deploying again.

  3. Usually husky is used for Git hooks, which should not be necessary in a production build. If you don’t need husky to run on your DigitalOcean App Platform deployment, you can adjust the prepare script or remove it from the package.json so that it is not executed on the App Platform.

Let me know how it goes!

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

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel