每当我尝试运行ng serve
命令时,都会收到以下错误。下面是错误的详细信息。
ERROR in src/app/errorhandler/my-logger.service.ts(13,54): error TS2304: Cannot find name 'DOCUMENT'. src/app/excelDnload/excel-dnload.service.ts(20,53): error TS2304: Cannot find name
下面是我的package.json
文件
{
"name": "My-Application",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy-config.json",
"lint": "tslint \"src/**/*.ts\"",
"build": "ng build",
"prod": "ng build --prod --aot=false",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "7.2.16",
"@angular/common": "7.2.16",
"@angular/compiler": "7.2.16",
"@angular/core": "7.2.16",
"@angular/forms": "7.2.16",
"@angular/http": "7.2.16",
"@angular/platform-browser": "7.2.16",
"@angular/platform-browser-dynamic": "7.2.16",
"@angular/platform-server": "7.2.16",
"@angular/router": "7.2.16",
"@ng-idle/core": "7.0.0-beta.1",
"@ng-idle/keepalive": "7.0.0-beta.1",
"ag-grid": "14.2.0",
"ag-grid-angular": "14.2.0",
"angular-polyfills": "1.0.1",
"angular2-uuid": "1.1.1",
"bootstrap": "3.3.7",
"core-js": "2.5.3",
"exceljs": "1.0.0",
"file-saver": "1.3.3",
"font-awesome": "4.7.0",
"http-proxy": "1.16.2",
"node-sass": "^4.14.1",
"primeng": "4.3.0",
"rxjs": "6.3.0",
"rxjs-compat": "6.3.0",
"ts-helpers": "1.1.2",
"tslib": "1.9.0",
"xlsx": "0.10.9",
"zone.js": "0.8.20"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.0",
"@angular/cli": "7.3.10",
"@angular/compiler-cli": "7.2.16",
"@types/jasmine": "2.8.6",
"@types/jquery": "^3.5.3",
"@types/node": "7.0.57",
"@types/systemjs": "0.20.6",
"codelyzer": "^4.5.0",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.2.1",
"jquery": "3.3.1",
"jquery-ui": "1.12.1",
"karma": "1.3.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-html-reporter": "0.1.3",
"karma-htmlfile-reporter": "0.3.5",
"karma-jasmine": "1.1.1",
"karma-remap-istanbul": "0.2.2",
"karma-story-reporter": "0.3.1",
"protractor": "4.0.14",
"ts-node": "3.0.4",
"tslint": "5.9.1",
"typescript": "3.1.1"
}
}
和tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"paths": {
"exceljs":[
"../node_modules/exceljs/dist/es5/exceljs.browser"
]
}
},
"files": [
"typings/index.d.ts",
"main.ts",
"polyfills.ts"
]
}
到目前为止,我已经尝试过-
I replace "lib": ["es6", "dom"] in tsconfig file
with "lib": ["es2017","es2016", "es2015","esnext", "dom"],
and "lib": ["es5", "es6", "dom"],
and "lib": ["ES2016", "dom"],
and "lib": ["dom"],
但是他们都不起作用。