I created an angular project, and I got errors while running the code in vs code (Powershell terminal).
For npm start
, I got errors as following:
../node_modules/ionic-selectable/src/app/components/ionic-selectable/ionic-selectable.component.d.ts:19:9
- error TS1086: An accessor cannot be declared in an ambient context.
19 get _hasIonLabelCssClass(): boolean;
~~~~~~~~~~~~~~~~~~~~ ../node_modules/ionic-selectable/src/app/components/ionic-selectable/ionic-selectable.component.d.ts:20:9
- error TS1086: An accessor cannot be declared in an ambient context.
20 get _hasDefaultIonLabelCssClass(): boolean;
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../node_modules/ionic-selectable/src/app/components/ionic-selectable/ionic-selectable.component.d.ts:21:9
- error TS1086: An accessor cannot be declared in an ambient context.
I am using angular 8.
I have warning for compatibilities issues, but I don’t want to change the whole code for that – just doing the minimal changes neccessary.
My package.json looks like this:
{
"name": "MyProject",
"version": "x.x.x",
"author": "eitan",
"homepage": "****",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^8.2.14",
"@angular/core": "^8.2.14",
"@angular/fire": "^5.4.2",
"@angular/forms": "^8.2.14",
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@angular/pwa": "^0.803.25",
"@angular/router": "^8.2.14",
"@angular/service-worker": "^8.2.14",
"@capacitor/cli": "^2.4.1",
"@capacitor/core": "^2.4.1",
"@ionic-native/camera": "^5.28.0",
"@ionic-native/core": "^5.21.6",
"@ionic-native/splash-screen": "^5.21.6",
"@ionic-native/status-bar": "^5.21.6",
"@ionic/angular": "^5.0.1",
"@ionic/pwa-elements": "^3.0.1",
"@ionic/storage": "^2.2.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"core-js": "^2.6.11",
"echarts": "^4.6.0",
"firebase": "^7.24.0",
"highcharts": "^10.3.2",
"ionic-selectable": "^4.5.0",
"ngx-echarts": "^4.2.2",
"rxjs": "^6.5.4",
"rxjs-compat": "^6.5.4",
"tslib": "^1.11.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/architect": "^0.803.25",
"@angular-devkit/build-angular": "^0.803.29",
"@angular-devkit/core": "^8.3.25",
"@angular-devkit/schematics": "^8.3.25",
"@angular/cli": "8.3.2",
"@angular/compiler": "^8.2.14",
"@angular/compiler-cli": "^8.2.14",
"@angular/language-service": "^8.2.14",
"@ionic/angular-toolkit": "^2.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "^2.0.8",
"@types/node": "12.12.0",
"codelyzer": "^5.2.1",
"firebase-tools": "^7.12.0",
"fuzzy": "^0.1.3",
"inquirer": "^6.2.2",
"inquirer-autocomplete-prompt": "^1.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.3",
"ts-node": "~8.1.0",
"tslint": "~5.17.0",
"typescript": "~3.5.3"
},
"description": "Plant sharp mobile application"
}
and tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
I did:
nvm install 12
nvm use 12
I clean cache and remove the the node-modules
For nvm the path was: “C:Program Filesnodejs”, as I checked:
npm config get prefix
and in powershell:
$env:NPM_GLOBAL="$env:NPM_GLOBAL="C:Program Filesnodejsbin"
[Environment]::SetEnvironmentVariable("PATH", $env:NPM_GLOBAL + ";" + $env:PATH, [EnvironmentVariableTarget]::User)
I did some global installations:
npm install -g @angular/cli@8
npm install -g npm-check-updates
npm install -g ionic
npm install -g firebase-tools
npm install -g lighthouse
and npm install
I checked version compatibility, but I didn’t see any information for “typescript” package integrated with “@types/node” package “package.json” file.
(Seen in: Version compatibility)
I presume that I have wrong typescript versions (hopefully, that’s the only disparity that should be corrected).
What can be done?
Thanks.