When attempting to build and run the angular project with a dotnet backend I receive the following errors.
info: Microsoft.AspNetCore.SpaServices[0]
ERROR in ../../../../node_modules/@angular/common/common.d.ts(1208,17): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/common/common.d.ts(1271,42): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/common/common.d.ts(2423,26): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/core/core.d.ts(214,21): error TS1039: Initializers are not allowed in ambient contexts.
../../../../node_modules/@angular/core/core.d.ts(5347,22): error TS1039: Initializers are not allowed in ambient contexts.
../../../../node_modules/@angular/core/core.d.ts(10292,36): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
../../../../node_modules/@angular/core/core.d.ts(10963,55): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
../../../../node_modules/@angular/core/core.d.ts(11961,12): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/core/core.d.ts(12448,12): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/rxjs/internal/symbol/observable.d.ts(4,9): error TS2687: All declarations of 'observable' must have identical modifiers.
Microsoft.AspNetCore.SpaServices:Information: ERROR in ../../../../node_modules/@angular/common/common.d.ts(1208,17): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/common/common.d.ts(1271,42): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/common/common.d.ts(2423,26): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/core/core.d.ts(214,21): error TS1039: Initializers are not allowed in ambient contexts.
../../../../node_modules/@angular/core/core.d.ts(5347,22): error TS1039: Initializers are not allowed in ambient contexts.
../../../../node_modules/@angular/core/core.d.ts(10292,36): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
../../../../node_modules/@angular/core/core.d.ts(10963,55): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
../../../../node_modules/@angular/core/core.d.ts(11961,12): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/core/core.d.ts(12448,12): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/rxjs/internal/symbol/observable.d.ts(4,9): error TS2687: All declarations of 'observable' must have identical modifiers.
These errors occurred as the result of some installs attempted to add angular packages needed to support the "import {Router} from "@angular/router";" present in the Okta Angular sample application. The use of this import can be found in the app.component.ts file of that example project.
Installs I was prompted to do for that import statement include:
@angular/router
@angular/core
@angular/common
All of these were installed locally in the project and globally using npm.
IDE - Visual Studio Code
Other internet posts have said that this is due to an issue in the version of Typescript being used since the "unknown" keyword was added in Typescript 3.0.
I have followed all of the guidance about updating my version of typescript again both globally and locally. I have also installed the tsd - typescript dictionary package another post recommended to no avail. I cannot seem to get past this error message.
package.json included here for reference
{
"name": "VerifyMe",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run VerifyMe:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "6.1.10",
"@angular/common": "6.1.10",
"@angular/compiler": "6.1.10",
"@angular/core": "6.1.10",
"@angular/forms": "6.1.10",
"@angular/http": "6.1.10",
"@angular/platform-browser": "6.1.10",
"@angular/platform-browser-dynamic": "6.1.10",
"@angular/platform-server": "6.1.10",
"@angular/router": "6.1.10",
"@nguniversal/module-map-ngfactory-loader": "6.0.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.3.1",
"jquery": "3.3.1",
"popper.js": "^1.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.0",
"@angular/cli": "~6.0.0",
"@angular/compiler-cli": "6.1.10",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"typescript": "~2.7.2"
},
"optionalDependencies": {
"node-sass": "^4.9.3",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}
From your package.json
it looks like you are still using typescript@2 so you can either try update npm i -D typescript@3
or add "skipLibCheck": true
to your tsconfig.