Skip to content

module 'tslib' cannot be found #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GaryB432 opened this issue Dec 15, 2016 · 10 comments
Closed

module 'tslib' cannot be found #12

GaryB432 opened this issue Dec 15, 2016 · 10 comments

Comments

@GaryB432
Copy link

Hi guys. I'm getting this error when I run `node_modules/.bin/tsc' in the following folder.

error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.

The offending line (rxjs/Subscriber.d.ts(13,36) does indeed include an innocent looking extend keyword. Can you tell me what I'm doing wrong?

$ node_modules/.bin/tsc
node_modules/rxjs/Subscriber.d.ts(13,36): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.

src/main.ts

import { Observable } from "rxjs";

Observable.timer(3000, 5000)
  .timeInterval()
  .subscribe((interval) => console.log(interval));

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "importHelpers": true,
    "target": "es5",
    "noEmitHelpers": true
  }
}

package.json

{
  "name": "stuff",
  "version": "1.0.0",
  "scripts": {
    "build": "webpack"
  },
  "devDependencies": {
    "@types/core-js": "^0.9.35",
    "ts-loader": "^1.3.2",
    "typescript": "^2.1.4",
    "webpack": "^2.1.0-beta.25"
  },
  "dependencies": {
    "rxjs": "^5.0.1",
    "tslib": "^1.2.0"
  }
}

rxjs/Subscriber.d.ts(13)

export declare class Subscriber<T> extends Subscription implements Observer<T> {

I posted my question to stackoverflow but can't get any interest

@mhegazy
Copy link
Contributor

mhegazy commented Dec 15, 2016

Looks like a duplicate of microsoft/TypeScript#12724

can you give [email protected] a try?

@GaryB432
Copy link
Author

yeah that seems to work. thanks! I guess I'll wait for 2.2 to go to latest before leaving ts-helpers behind

@mhegazy
Copy link
Contributor

mhegazy commented Dec 15, 2016

We should be publishing 2.1.5 with he fix soon.

@garthk
Copy link

garthk commented Jan 4, 2017

@mhegazy any clarity you can offer on "soon"?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 4, 2017

We are targeting next week.

@Strato
Copy link

Strato commented Jan 13, 2017

Hello,

I've installed TypeScript 2.1.5 Tools for Visual Studio as well as the npm package globally AND in my project, and I'm still getting red squiggly lines under code like this:

extends React.Component<{}, {}>

Tooltip error being this syntax requires an imported helper but module 'tslib' cannot be found.

Note that it doesn't prevent the project from being transpiled.

TSLib 1.5.0 is in my package.json dependencies section, and it's in node_modules. tsconfig has importHelpers = true.

Since it's Visual Studio related I tried to add this line (not documented but makes sense) in my .csproj:

<TypeScriptImportHelpers>True</TypeScriptImportHelpers>

I'm not supposed to import it explicitly, do I? Or maybe point to a definition file?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 13, 2017

@Strato, this looks like a bug do you mind filing a new issue under https://github.com/Microsoft/TypeScript/issues

@Strato
Copy link

Strato commented Jan 16, 2017

Done.

@rahulswimmer
Copy link

rahulswimmer commented Jul 24, 2018

Following is my package.json

 {
   "name": "digital-labels",
   "version": "0.0.0",
   "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "compodoc": "compodoc -p src/tsconfig.app.json"
 },
  "private": true,
  "dependencies": {
  "@angular/animations": "^6.0.7",
  "@angular/cdk": "^6.3.2",
  "@angular/common": "^6.0.3",
  "@angular/compiler": "^6.0.3",
  "@angular/core": "^6.0.3",
  "@angular/forms": "^6.0.3",
  "@angular/http": "^6.0.3",
  "@angular/material": "^6.3.2",
  "@angular/platform-browser": "^6.0.3",
  "@angular/platform-browser-dynamic": "^6.0.3",
  "@angular/pwa": "^0.6.8",
  "@angular/router": "^6.0.3",
  "@angular/service-worker": "^6.0.3",
  "@ng-idle/core": "^6.0.0-beta.3",
  "angularx-social-login": "^1.2.0",
  "core-js": "^2.5.4",
  "hammerjs": "^2.0.8",
  "hide-virtual-keyboard": "^1.0.1",
  "ng2-avatar": "^2.3.1",
  "ng2-search-filter": "^0.4.7",
  "rxjs": "^6.0.0",
  "tslib": "^1.9.3",
  "zone.js": "^0.8.26"
  },
  "devDependencies": {
  "@angular-devkit/build-angular": "~0.6.8",
  "@angular/cli": "~6.0.8",
  "@angular/compiler-cli": "^6.0.3",
  "@angular/language-service": "^6.0.3",
  "@compodoc/compodoc": "^1.1.3",
  "@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": "~1.7.1",
  "karma-chrome-launcher": "~2.2.0",
  "karma-coverage-istanbul-reporter": "~2.0.0",
  "karma-jasmine": "~1.1.1",
  "karma-jasmine-html-reporter": "^0.2.2",
  "protractor": "~5.3.0",
  "ts-node": "~5.0.1",
  "tslint": "~5.9.1",
  "typescript": "~2.7.2"
  },
  "description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) 
   version 6.0.8.",
 "main": "index.js",
 "repository": {
  "type": "git",
     "url": "git+https://[email protected]/morrisonsplc/esels-digital-labels-pwa.git"
  },
  "author": "",
  "license": "ISC",
  "homepage": "https://bitbucket.org/morrisonsplc/esels-digital-labels-pwa#readme"
 }

Once i run 'ng test', i receive the following errors:

  1. No captured browser, open http://localhost:9876/
  2. Uncaught Error: Cannot find module "tslib".

I deleted node_modules and ran 'npm install'. But this solution didn't work.
What should i do? I can't run karma test runner and hence a blocker in my test driven development cycle.
Please suggest me a solution!

@tony2tones
Copy link

try npm install --save tslib, thats what helped me out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants