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!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
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 thenest
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 underdevDependencies
in yourpackage.json
. The App Platform build environment installs packages listed indevDependencies
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:If the issue persists, consider using a custom build command in your DigitalOcean App Platform settings:
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