Search code examples
angularangular-clitsickle

Can't create new project in Angular: tsickle dependency problem


I've installed:

  • node.js v15.6.0
  • npm 7.5.0
  • Angular CLI: 11.1.2

I'm running on Windows 10, 64bit.

I'm trying to create my first project by running:

ng new angular-demo

where "angular-demo" is project name. The command creates a project directory with some initial files, then it runs npm and fails with the following messages in the log file

67 verbose argv "W:\\nodejs\\node.exe" "C:\\Users\\Tomasz\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
68 verbose node v15.6.0
69 verbose npm  v7.5.0
70 error code ERESOLVE
71 error ERESOLVE unable to resolve dependency tree
72 error
73 error While resolving: angular-demo@0.0.0
73 error Found: typescript@4.1.3
73 error node_modules/typescript
73 error   peer typescript@"~4.0.0 || ~4.1.0" from @angular-devkit/build-angular@0.1101.2
73 error   node_modules/@angular-devkit/build-angular
73 error   peer typescript@">=4.0 <4.2" from @angular/compiler-cli@11.1.1
73 error   node_modules/@angular/compiler-cli
73 error     peer @angular/compiler-cli@"^11.0.0 || ^11.1.0-next" from @angular-devkit/build-angular@0.1101.2
73 error     node_modules/@angular-devkit/build-angular
73 error     peer @angular/compiler-cli@"11.1.1" from @angular/localize@11.1.1
73 error     node_modules/@angular/localize
73 error       peerOptional @angular/localize@"^11.0.0 || ^11.1.0-next" from @angular-devkit/build-angular@0.1101.2
73 error       node_modules/@angular-devkit/build-angular
73 error     1 more (ng-packagr)
73 error   1 more (ng-packagr)
73 error
73 error Could not resolve dependency:
73 error peer typescript@"~3.9.5" from tsickle@0.39.1
73 error node_modules/tsickle
73 error   peerOptional tsickle@"~0.39.0" from ng-packagr@11.1.2
73 error   node_modules/ng-packagr
73 error     peerOptional ng-packagr@"^11.0.0 || ^11.1.0-next" from @angular-devkit/build-angular@0.1101.2
73 error     node_modules/@angular-devkit/build-angular

I googled a bit and found that tsickle is some typescript-related tool and it supports only typescript version up to 3, not 4. I don't know why angular tries to install this combination of typescript version and tsickle.


Solution

  • a solution that worked for me was a combination of the solution proposed by @ypolonsky ... but I added another step. The solution is to uninstall everything (even global node modules manually) and then reinstall Node.

    I am working on a Windows 10 machine and the next steps solved the problem for me:

    1. First, delete all the content inside: C:\Users\your_user\AppData\Roaming\npm . This step is needed because this content is not deleted automatically on the uninstall process.
    2. Then, uninstall Node (you can do it from Control Panel)
    3. Open https://nodejs.org/en/download/ and select LTS latest version (as suggested by ypolonsky)
    4. Install Node
    5. Install the Angular cli: npm install -g @angular/cli
    6. Test creating a new Angular project again, it should work (the process takes some time so be patient): ng new my-app

    In my case the problem probably was that I didn't updated Node from a long time and I have been doing a lot of updates (using ncu command) of my global packages as well, so a clean install was needed.

    This post helped me to find out how to delete my node global modules: Command to remove all npm modules globally?