When I try to build an Angular project I have this issue :
File '/angular/src/environments/environment.ts' is not a module
I import the file like this :
import { environment } from '../../environments/environment';
My tsconfig.json :
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
In my environment folder I have files: environment.ts, environment.prod.ts, environment.dev.ts.
I use NODE_VERSION=10, NG_CLI_VERSION=8
My angular.json, the build.configurations for dev :
"dev": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"serviceWorker": true
}
Command for build : "build": "ng build --configuration=dev --aot",
Please help me. Thanks in advance !
Angular by default only configures the
angular.jsonproduction environment to replace theenvironement.tsfile. It uses this part ofangular.json.Not for dev to use
environment.dev.tsyou would need to add thefileReplacementspart to dev build too.Or place your dev config to the non-post-fixed one.