5

Basically, all I'm doing is starting a new Angular project and loading it into a workspace. It doesn't look as if VS Code can do any linting or code sense because of this error. It's spitting up this error data:

{
    "resource": "/Users/<snip!>/angular-project/src/app/app.module.ts",
    "owner": "typescript",
    "code": "2354",
    "severity": 8,
    "message": "This syntax requires an imported helper but module 'tslib' cannot be found.",
    "source": "ts",
    "startLineNumber": 13,
    "startColumn": 1,
    "endLineNumber": 26,
    "endColumn": 3
}

I found an old bug somewhere that said moduleResolution of tsconfig.json had to be set to node, but Angular CLI has already done that for me...

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "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"
    ]
  }
}

Edit: Steps I took to get here (using version 8 as of this writing):

  1. Install Angular CLI: $ npm install -g @angular/cli
  2. Create the project: $ ng new angular-project
  3. Serve the project: $ ng serve

Does anyone know how to solve this?

3
  • What is the angular version ? Also could you upload the code that show the error or take a screen shot of it Commented Jun 14, 2019 at 4:16
  • I could... but I've tried manipulating code to try to get rid of it and any code in the project that gets evaluated gives the same error. Commented Jun 14, 2019 at 14:03
  • FWIW I'm using the latest angular stuffs and CLI. Version 8.0.2 Commented Jun 14, 2019 at 14:04

1 Answer 1

7

Below is my package.json file using angular 8. Check to see if you have tslib install or not.

Also delete package-lock.json and delete node_modules folder then run npm i again

{
  "name": "ngrx",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.0.0",
    "@angular/common": "~8.0.0",
    "@angular/compiler": "~8.0.0",
    "@angular/core": "~8.0.0",
    "@angular/forms": "~8.0.0",
    "@angular/platform-browser": "~8.0.0",
    "@angular/platform-browser-dynamic": "~8.0.0",
    "@angular/router": "~8.0.0",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0",
    "@angular/cli": "~8.0.0",
    "@angular/compiler-cli": "~8.0.0",
    "@angular/language-service": "~8.0.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.