Reputation: 1328
I am struggling with the following error:
error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
baseUrl: process.env.TEST
// environment.prod.ts
import 'dotenv/config';
export const environment = {
production: true,
baseUrl: process.env.TEST
};
//.env
TEST=whatever
I've already installed @types/node and dotenv, the problem is the IDE on typescript files is telling me there is something wrong with TEST, what am I missing?
Upvotes: 1
Views: 625
Reputation: 384
Its not enough to install dotenv
package, it's types and use it right after with process.env.TEST
You also have to configure your dotenv
package in App.ts
or any root file of an application you have
something like this:
dotenv.config({ path: __dirname + `/../.production.env}` })
Upvotes: 2