当我尝试构建一个 Angular 项目时,我遇到了这个问题:
文件“/angular/src/environments/environment.ts”不是模块
我像这样导入文件:
import { environment } from '../../environments/environment';
我的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"
]
}
}
在我的环境文件夹中,我有文件:environment.ts
, environment.prod.ts
, environment.dev.ts
.
我使用 NODE_VERSION=10, NG_CLI_VERSION=8
我的 angular.json,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
}
构建命令:"build": "ng build --configuration=dev --aot",
请帮我。提前致谢 !