Question

Cannot run nestjs app

Hi all

I tried to deploy an app (simple api) running nestjs and I am unable to do that. I get the following error

psymbl-api | 03:00:10 => Initializing build
psymbl-api | 03:00:10 => Retrieving source code to /workspace
psymbl-api | 03:00:10 => Selecting branch "main"
psymbl-api | 03:00:12 => Checking out commit "f6f1aa1ce5fd25c6305f03be6e6f16a45ef1af3b"
psymbl-api | 03:00:12 => Validating environment
psymbl-api | 03:00:12 
psymbl-api | 03:00:12 => Building app using buildpacks
psymbl-api | 03:00:12 => Injecting app environment variables:
psymbl-api | 03:00:12      SENDGRID_API_KEY AUTH0_DOMAIN DB_PORT AUTH0_CLIENT_SECRET SERVER_PORT DB_CONNECTION_STRING_INTERNAL_VPC AUTH0_CLIENT_ID JWT_SECRET DB_PASSWORD DB_SSL_MODE DB_HOST_INTERNAL_VPC DB_HOST DB_CERT SESSION_SECRET DB_USERNAME AUTH0_AUDIENCE DB_CONNECTION_STRING DB_DATABASE
psymbl-api | 03:00:12 => Configuring custom build command to be run at the end of the build:
psymbl-api | 03:00:12      npm run build
psymbl-api | 03:00:12 => Running buildpack detection
psymbl-api | 03:00:12 
psymbl-api | 03:00:13 heroku/nodejs-engine  0.5.0
psymbl-api | 03:00:13 digitalocean/node     0.2.0
psymbl-api | 03:00:13 digitalocean/procfile 0.0.3
psymbl-api | 03:00:13 digitalocean/custom   0.1.0
psymbl-api | 03:00:13 
psymbl-api | 03:00:13 
psymbl-api | 03:00:13 => Building app
psymbl-api | 03:00:13 
psymbl-api | 03:00:13 ---> Node.js Buildpack
psymbl-api | 03:00:13 ---> Installing toolbox
psymbl-api | 03:00:13 ---> - jq
psymbl-api | 03:00:13 ---> - yj
psymbl-api | 03:00:14 ---> Getting Node version
psymbl-api | 03:00:14 ---> Resolving Node version
psymbl-api | 03:00:16 ---> Downloading and extracting Node v12.20.2
psymbl-api | 03:00:30 ---> Parsing package.json
psymbl-api | 03:00:31 ---> No file to start server
psymbl-api | 03:00:31 ---> either use 'docker run' to start container or add index.js or server.js
psymbl-api | 03:00:31 Installing node_modules using npm (from package-lock.json)
psymbl-api | 03:00:55 
psymbl-api | 03:00:55 > core-js@3.8.3 postinstall /workspace/node_modules/core-js
psymbl-api | 03:00:55 > node -e "try{require('./postinstall')}catch(e){}"
psymbl-api | 03:00:55 
psymbl-api | 03:00:55 Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
psymbl-api | 03:00:55 
psymbl-api | 03:00:55 The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
psymbl-api | 03:00:55 > https://opencollective.com/core-js 
psymbl-api | 03:00:55 > https://www.patreon.com/zloirock 
psymbl-api | 03:00:55 
psymbl-api | 03:00:55 Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
psymbl-api | 03:00:55 
psymbl-api | 03:00:56 
psymbl-api | 03:00:56 > bcrypt@5.0.0 install /workspace/node_modules/bcrypt
psymbl-api | 03:00:56 > node-pre-gyp install --fallback-to-build
psymbl-api | 03:00:56 
psymbl-api | 03:00:56 node-pre-gyp WARN Using request for node-pre-gyp https download 
psymbl-api | 03:00:57 [bcrypt] Success: "/workspace/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remote
psymbl-api | 03:00:57 
psymbl-api | 03:00:57 > @nestjs/core@7.6.12 postinstall /workspace/node_modules/@nestjs/core
psymbl-api | 03:00:57 > opencollective || exit 0
psymbl-api | 03:00:57 
psymbl-api | 03:00:57                            Thanks for installing nest 
psymbl-api | 03:00:57                  Please consider donating to our open collective
psymbl-api | 03:00:57                         to help us maintain this package.
psymbl-api | 03:00:57                                          
psymbl-api | 03:00:57                             Number of contributors: 0
psymbl-api | 03:00:57                               Number of backers: 505
psymbl-api | 03:00:57                               Annual budget: $50,588
psymbl-api | 03:00:57                              Current balance: $5,140
psymbl-api | 03:00:57                                          
psymbl-api | 03:00:57              Become a partner: https://opencollective.com/nest/donate
psymbl-api | 03:00:57                                          
psymbl-api | 03:00:58 
psymbl-api | 03:00:58 > fsevents@1.2.13 install /workspace/node_modules/nodemon/node_modules/fsevents
psymbl-api | 03:00:58 > node install.js
psymbl-api | 03:00:58 
psymbl-api | 03:00:58 
psymbl-api | 03:00:58 Skipping 'fsevents' build as platform linux is not supported
psymbl-api | 03:00:58 
psymbl-api | 03:00:58 > nodemon@1.19.4 postinstall /workspace/node_modules/nodemon
psymbl-api | 03:00:58 > node bin/postinstall || exit 0
psymbl-api | 03:00:58 
psymbl-api | 03:00:59 Love nodemon? You can now support the project via the open collective:
psymbl-api | 03:00:59  > https://opencollective.com/nodemon/donate
psymbl-api | 03:00:59 
psymbl-api | 03:00:59 added 1276 packages in 27.323s
psymbl-api | 03:01:08 Running custom build command: npm run build
psymbl-api | 03:01:09 
psymbl-api | 03:01:09 > psymbl@0.0.1 prebuild /workspace
psymbl-api | 03:01:09 > rimraf dist
psymbl-api | 03:01:09 
psymbl-api | 03:01:09 
psymbl-api | 03:01:09 > psymbl@0.0.1 build /workspace
psymbl-api | 03:01:09 > nest build
psymbl-api | 03:01:09 
psymbl-api | 03:01:09 sh: 1: nest: not found
psymbl-api | 03:01:09 npm ERR! code ELIFECYCLE
psymbl-api | 03:01:09 npm ERR! syscall spawn
psymbl-api | 03:01:09 npm ERR! file sh
psymbl-api | 03:01:09 npm ERR! errno ENOENT
psymbl-api | 03:01:09 npm ERR! psymbl@0.0.1 build: `nest build`
psymbl-api | 03:01:09 npm ERR! spawn ENOENT
psymbl-api | 03:01:09 npm ERR! 
psymbl-api | 03:01:09 npm ERR! Failed at the psymbl@0.0.1 build script.
psymbl-api | 03:01:09 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
psymbl-api | 03:01:09 
psymbl-api | 03:01:09 npm ERR! A complete log of this run can be found in:
psymbl-api | 03:01:09 npm ERR!     /home/apps/.npm/_logs/2021-02-17T02_01_09_721Z-debug.log
psymbl-api | 03:01:09 building: exit status 1
psymbl-api | 03:01:09 ERROR: failed to build: exit status 1
psymbl-api | 03:01:09  ! Build failed (145)

Can someone tell me if these arent supported and i should instead use a droplet only?

/Manuel


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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi! The problem is that npm/yarn do not install devDependencies if NODE_ENV variable set to production

I solved this problem by removing NODE_ENV from app configuration, and added NODE_ENV=production before running specific build script

npm install docs yarn install docs

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies. To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production, you can use --production=false.

Unfortunately, this post has not been updated; this issue is still happening.

I have had to create a new nest project, without adding any new code since the scaffolding, I cannot launch it.

I’m getting many types of errors :

  • “sh: 1: nest: not found” setting up NODE_ENV = production
  • “Missing dependencies, incompatible versions, incorrect environment variables or app bugs” using the scaffolded base code
  • “Memory exhaustion” afterward, I have added some controllers and dependencies

To make it work, I have had to use NODE_ENV = development and move devDependencies to the dependencies node.

Is there a solution for that?

hi there

This is nestjs not next.js.

Looks like it fails because nestjs cli needs to be installed and i wonder if theres a way to do so…