I am trying to build and deploy my NestJs server app DO “App” platform linking it to it’s github repository.
As any other NestJs app it has these scripts
"prebuild": "rimraf dist",
"build": "nest build",
Everything was working fine and deployment was successful at first, until suddenly it started failing in the building process giving me the following error.
sh: 1: rimraf: not found
Although I didn’t make any changes to package.json installing, removing or updating any package. Add to that the rimraf package is already included as a DevDependency.
And even when I change the prebuild script to rm -rf dist instead of rimraf dist which I don’t prefer. It gives me another error during the build
sh: 1: nest: not found
How come nest itself is not found. It’s a NestJs app ??
And BTW everything is working perfectly on local machine, and I am not using docker with that project
I also tried to force rebuild and deploy, and even destroyed the whole app and created it from scratch once again … same errors
I don’t understand why that started happening? and how can I fix that?
wish you can help. 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!
Hi there,
The issues you’re encountering during the build and deployment process on DigitalOcean’s App Platform seem to be related to the environment’s handling of your application’s dependencies, particularly rimraf and the nest CLI.
These errors often occur when dependencies are not installed or not available in the PATH of the build environment. Here are some steps to troubleshoot and resolve these issues:
Ensure that rimraf and @nestjs/cli are correctly listed under devDependencies in your package.json. The App Platform build environment installs packages listed in devDependencies during the build process.
The build environment should correctly recognize your application as a Node.js app. Ensure your package.json is correctly configured and is in the root of your repository.
Leverage NPM scripts to handle the build process. Modify your package.json scripts to explicitly use local node_modules binaries:
"scripts": {
"prebuild": "./node_modules/.bin/rimraf dist",
"build": "./node_modules/.bin/nest build",
// other scripts...
}
If the issue persists, consider using a custom build command in your DigitalOcean App Platform settings:
npm install && npm run build
As a last resort, consider containerizing your application using Docker. This will allow you to define the environment in which your app builds and runs, making it more consistent across local and production environments. You mentioned not using Docker, but it can sometimes offer more control over the deployment process.
Also if your project is open-source, feel free to share the link to your GitHub repository here and I can try deploying it on my and and further investigate 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.