Yarn: Yarn fails to install dependencies when rxjs-tslint is present (could not find a copy of typescript to link)

Created on 10 Dec 2018  路  3Comments  路  Source: yarnpkg/yarn

Reproduction steps;

  1. Define the following package.json:
"dependencies": {
    "@angular/animations": "~7.0.0",
    "@angular/cdk": "~7.0.1",
    "@angular/cdk-experimental": "~7.1.0",
    "@angular/common": "~7.0.0",
    "@angular/compiler": "~7.0.0",
    "@angular/core": "~7.0.0",
    "@angular/forms": "~7.0.0",
    "@angular/http": "~7.0.0",
    "@angular/material": "~7.0.1",
    "@angular/platform-browser": "~7.0.0",
    "@angular/platform-browser-dynamic": "~7.0.0",
    "@angular/router": "~7.0.0",
    "@ngrx/store": "~6.1.2",
    "@ngx-translate/core": "~11.0.0",
    "@ngx-translate/http-loader": "~4.0.0",
    "@swimlane/ngx-datatable": "~14.0.0",
    "@zxing/library": "0.8.3",
    "angular-gridster2": "7.0.0",
    "bootstrap": "~3.3.7",
    "core-js": "~2.5.1",
    "cropperjs": "~1.4.3",
    "hammerjs": "~2.0.8",
    "html2canvas": "~1.0.0-alpha.12",
    "mobile-drag-drop": "~2.3.0-rc.1",
    "moment": "~2.22.1",
    "ng2-dnd": "~5.0.2",
    "ng2-file-upload": "~1.3.0",
    "ngx-bootstrap": "~3.0.1",
    "ngx-toastr": "~9.1.1",
    "rxjs": "~6.3.3",
    "tinymce": "~4.8.5",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/cli": "~7.0.2",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/language-service": "~7.0.0",
    "@ngrx/store-devtools": "~6.1.2",
    "@types/cropperjs": "~1.1.3",
    "@types/html2canvas": "~0.0.35",
    "@types/jasmine": "~2.8.9",
    "@types/jasminewd2": "~2.0.5",
    "@types/node": "~10.12.0",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.9.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-edge-launcher": "~0.4.2",
    "karma-firefox-launcher": "~1.1.0",
    "karma-ie-launcher": "~1.0.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "~0.2.2",
    "karma-junit-reporter": "~1.2.0",
    "ng-mocks": "~7.0.1",
    "rxjs-tslint": "~0.1.6",
    "sass-lint": "~1.12.1",
    "ts-node": "~7.0.1",
    "tslint": "~5.11.0",
    "typescript": "~3.1.3",
    "webpack-bundle-analyzer": "~3.0.3"
  }
  1. Run yarn.
  2. Error is thrown:
error An unexpected error occurred: "could not find a copy of typescript to link in C:
\\(...)\\node_modules\\rxjs-tslint\\node_modules".

I guess this could be helpful - when I remove rxjs-tslint from the package.json, yarn completes successfully. I can even add this dependency later using yarn add rxjs-tslint --dev without any error messages.

What is the expected behavior?
Dependencies are installed without errors (like it happens in NPM).

Please mention your node.js, yarn and operating system version.

$ node -v
v8.11.1
$ yarn -v
1.12.3

OS: Windows 10

PS: Please let me know if this bug should be reported in rxjs-tslint package instead. I figured that it should be reported here because NPM install the beforementioned packages without any problems.

Most helpful comment

^0.1.5 will still resolve to 0.1.6. ^ means "use the most recent minor version".
It should revert back to 0.1.5 if you use 0.1.5.

All 3 comments

Could this be a problem with the handling of transitive dependencies in yarn?
For me this problem appeared after if fixed the har-validator unpublish breakage (#6702) with a yarn upgrade, which did upgrade rxjs-tslint which added the typescript dependency:

 rxjs-tslint@^0.1.5:
-  version "0.1.5"
-  resolved "https://registry.yarnpkg.com/rxjs-tslint/-/rxjs-tslint-0.1.5.tgz#9cddba80633e155fb47f7f0a25a6e33971f7dbf9"
-  integrity sha512-odvEAx6VoZSJs5o9gWZ7SxgTuS8ldq0mr4qnprbr6flNtIt4DtNJSYJpBK0WEy0o+f1oe92XVHrmgco1e7Cpdw==
+  version "0.1.6"
+  resolved "https://registry.yarnpkg.com/rxjs-tslint/-/rxjs-tslint-0.1.6.tgz#ada589279369b2ffd72a00c9d9e255f9be088049"
+  integrity sha512-AxP+/o2NduL7bVijrAJztZXhVk9AFzEj/ouyROnIqLb9gnLp6YB11QzSvIrKbnq2Mb+mF294EsOuoyMiRnFtlA==
   dependencies:
     chalk "^2.4.0"
     optimist "^0.6.1"
     tslint "^5.9.1"
     tsutils "^2.25.0"
+    typescript "^2.8.3"

The rxjs-tslint package now depdens on typescript ^2.8.3 while the project uses 3.x

If I run npm install I end up with typescript 2.x linked into the package:

$ ls node_modules/rxjs-tslint/node_modules/
typescript
$ cat node_modules/rxjs-tslint/node_modules/typescript/package.json | grep version
    "type": "version",
  "version": "2.9.2"

Related: ReactiveX/rxjs-tslint/issues/59

A Workaround is to revert rxjs-tslint back to 0.1.5

Reverting to 0.1.5 did not solve it for me. I have typescript : typescript": "^3.1.6"and "rxjs-tslint": "^0.1.5"

^0.1.5 will still resolve to 0.1.6. ^ means "use the most recent minor version".
It should revert back to 0.1.5 if you use 0.1.5.

Was this page helpful?
0 / 5 - 0 ratings