Angular CLI: 7.2.3
Node: 11.6.0
OS: darwin x64
Angular: 7.2.2
ERROR in ./node_modules/dotenv/lib/main.js
Module not found: Error: Can't resolve 'fs' in '/node_modules/dotenv/lib'
import * as dotenv from "dotenv";
dotenv.config();
export const environment = {
production: false,
'baseurl': process.env.BASEURL
};
{
"compileOnSave": false,
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es6",
"paths": {
"@app/*": ["app/*"]
},
"types": [
// add node as an option
"node"
],
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom",
"es5",
"es6"
]
}
}
i'm working with angular and use library for .env file.it's work good for node but when i'm used with typescript it gives me error.how to solve ?
You should only use dotenv in Node.js projects or at build time for browser-based projects like with Angular. Removing dotenv from your client-side code will resolve this error.
any solution to fix it?
Why is it closed? Nothing was solved here.
Most helpful comment
Why is it closed? Nothing was solved here.