Cannot find name 'process'

I’m was trying to deploy my nestjs application, after I set NODE_ENV to production, everything crashed.
I tried to add @types/node, but it still is
My build command:
npm install;npm install @types/node; npx @nestjs/cli build
here some logs:

src/config/configuration.ts:2:18 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

Mar 5 07:23:05 PM

Mar 5 07:23:05 PM2 port: parseInt(process.env.PORT, 10) || 3000,

Mar 5 07:23:05 PM ~~~~~~~

Mar 5 07:23:05 PMsrc/config/configuration.ts:4:5 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

allowing us to see your package.json would be super helpful, first of all, highly unusual to install a npm package at build time, typically you would install the package while developing. assuming you have a commandline with your code you could make sure you have all the latest versions and install the package. after you do this, the package will be listed in your package.json
rm package-lock.json
npm i @types/node # this should of already been in there! but i digress
rm package-lock.json # again!
npm update --save # up to this point is all done in your dev environment

then, commit and push your changes.
then change the build command to:

npm run build

and if you are using the current nestjs defaults, the start command would be:

npm run start

good luck!

Hi,

We often see issues like this if you’ve manually set a NODE_ENV to production.

I would guess the missing types and CLI are in your devDependencies, which aren’t install in production mode (npm docs)

Render sets NODE_ENV by default. At build time, it’s not set, so all devDependencies would be installed. Then we automatically set it to production at runtime. This is covered in the docs here: https://docs.render.com/environment-variables#node

If you have a NODE_ENV I’d suggest removing it from the “Environment” tab and updating your Build Command to just:

npm install

Alan

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.