By BenStirrup
It seems the deployment of my production app (with a pro instance) does not successfully complete the npm ci command, according to the following error logs :
[2022-02-09 15:17:46] => Building app
[2022-02-09 15:17:46]
[2022-02-09 15:17:46] ---> Node.js Buildpack
[2022-02-09 15:17:46] ---> Installing toolbox
[2022-02-09 15:17:46] ---> - jq
[2022-02-09 15:17:47] ---> - yj
[2022-02-09 15:17:47] ---> Getting Node version
[2022-02-09 15:17:47] ---> Resolving Node version
[2022-02-09 15:17:50] ---> Downloading and extracting Node v16.13.2
[2022-02-09 15:18:05] ---> Parsing package.json
[2022-02-09 15:18:06] ---> No file to start server
[2022-02-09 15:18:06] ---> either use 'docker run' to start container or add index.js or server.js
[2022-02-09 15:18:06] Project contains package-lock.json, using npm
[2022-02-09 15:18:06] Using npm v8.1.2. To configure a different version of npm, set the engines.npm property in package.json.
[2022-02-09 15:18:06] See https://do.co/apps-buildpack-node for further instructions.
[2022-02-09 15:18:06] Installing node_modules using npm (from package-lock.json)
[2022-02-09 15:18:07] Running npm ci
[2022-02-09 15:18:07]
[2022-02-09 15:18:35]
[2022-02-09 15:18:35] > nesspay-backend@0.1.0 postinstall
[2022-02-09 15:18:35] > patch-package
[2022-02-09 15:18:35]
[2022-02-09 15:18:35] sh: 1: patch-package: not found
[2022-02-09 15:18:35] npm notice
[2022-02-09 15:18:35] npm notice New minor version of npm available! 8.1.2 -> 8.4.1
[2022-02-09 15:18:35] npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.4.1>
[2022-02-09 15:18:35] npm notice Run `npm install -g npm@8.4.1` to update!
[2022-02-09 15:18:35] npm notice
[2022-02-09 15:18:35] npm ERR! code 127
[2022-02-09 15:18:35] npm ERR! path /workspace
[2022-02-09 15:18:35] npm ERR! command failed
[2022-02-09 15:18:35] npm ERR! command sh -c patch-package
[2022-02-09 15:18:35]
[2022-02-09 15:18:35] npm ERR! A complete log of this run can be found in:
[2022-02-09 15:18:35] npm ERR! /home/apps/.npm/_logs/2022-02-09T15_18_35_748Z-debug.log
[2022-02-09 15:18:35]
[2022-02-09 15:18:35] unable to invoke layer creator
[2022-02-09 15:18:35] installing node_modules: exit status 127
[2022-02-09 15:18:35] ERROR: failed to build: exit status 1
It is super weird as I have the exact same configuration except for the type of database and instance size for a testing environment, which does not have this install node modules issue.
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!
Hi there,
The error log you provided indicates that the patch-package command is not found during the postinstall script execution in your package.json. This typically happens when patch-package is not installed or not correctly referenced in your dependencies.
Here are steps to troubleshoot and resolve the issue:
Make sure that patch-package is listed in your package.json under dependencies or devDependencies. It should look something like this:
"dependencies": {
"patch-package": "^6.4.7"
}
If you have an .npmrc file in your project, make sure it’s not configured in a way that would prevent the installation of patch-package.
Sometimes, old build caches can cause issues. You can try redeploying with a cleared build cache on the DigitalOcean App Platform to ensure that it’s not a caching issue.
Your postinstall script in package.json should correctly invoke patch-package. It typically looks like this:
"scripts": {
"postinstall": "patch-package"
}
Try running npm ci locally in your project directory to see if the postinstall script executes successfully. If it fails locally as well, then there’s likely an issue with how your project is configured.
Ensure that the Node.js version and npm version are consistent between your local environment, testing environment, and production environment. Use the engines field in package.json to specify the Node.js version:
"engines": {
"node": "18.x"
}
Since you mentioned that a testing environment works fine, compare the configuration and package.json of both environments to spot any discrepancies. And also review the full deployment logs to check if there are any other errors or warnings that might provide more context about the issue.
Best,
Bobby
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.