Jay Dharmendra Solanki
Jay Dharmendra Solanki

Reputation: 579

Latest Angular cli fails to create new app on Windows

On my windows 10 machine, I was trying to create the latest angular app using ng new myapp (cli version 9.0.1) with Angular v9. (Node version v12.15.0)

I have already tried the following from related questions on stackoverflow:

  1. uninstall angular cli (npm uninstall -g @angular/cli)
  2. npm cache clean and npm cache verify
  3. reinstall Node JS
  4. install angular again npm install -g @angular/cli
  5. Tried running cmd in Admin mode

I get the following error:

...
CREATE myapp2/e2e/src/app.po.ts (301 bytes)
- Installing packages...npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! Unexpected end of JSON input while parsing near '...strument":"^1.0.0-alp'
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jayds\AppData\Roaming\npm-cache\_logs\2020-02-12T07_00_06_637Z-debug.log
× Package install failed, see above.
The Schematic workflow failed. See above.

From the Log File:

...
5026 silly saveTree +-- [email protected]
5026 silly saveTree +-- [email protected]
5026 silly saveTree +-- [email protected]
5026 silly saveTree `-- [email protected]
5027 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...strument":"^1.0.0-alp'
5027 verbose stack     at JSON.parse (<anonymous>)
5027 verbose stack     at parseJson (C:\Users\jayds\Downloads\Softwares\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
5027 verbose stack     at C:\Users\jayds\Downloads\Softwares\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
5027 verbose stack     at runMicrotasks (<anonymous>)
5027 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:94:5)
5028 verbose cwd C:\Users\jayds\Projects\myapp2
5029 verbose Windows_NT 10.0.17763
5030 verbose argv "C:\\Users\\jayds\\Downloads\\Softwares\\nodejs\\node.exe" "C:\\Users\\jayds\\Downloads\\Softwares\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
5031 verbose node v12.15.0
5032 verbose npm  v6.13.4
5033 error Unexpected end of JSON input while parsing near '...strument":"^1.0.0-alp'
5034 verbose exit [ 1, true ]

Surprisingly it works on my Friend's Mac Book. I tried multiple times to re-install node and angular cli on windows but it still gives me this error.

Can someone please help me with this and make it work on Windows 10?

Note: I know there are other questions related to this but those were posted are outdated and with a different version of Angular. Although I tried their solutions as well, but I had no luck.

Upvotes: 2

Views: 2597

Answers (3)

Poode
Poode

Reputation: 1752

Please check your node version as Angular 9 using the LTS node version which is 12 for now as per https://angular.io/guide/setup-local#nodejs, and please if you faced a problem related to the module (error-ex) as 404 response during installing angular using npm install -g @angular/cli, then try this command in your terminal npm config set registry https://skimdb.npmjs.com/registry, and then try npm install -g @angular/cli again

Upvotes: 0

Abdel Ali
Abdel Ali

Reputation: 31

as a temporary fix you can manually install "error-ex" module directly from GitHub then install your dependencies as mentioned here facebook/create-react-app#8465 (comment)

$ npm i https://github.com/Qix-/node-error-ex

$ npm i

Upvotes: 0

sacgro
sacgro

Reputation: 469

npm cache clean --force
npm install -g @angular/cli@latest

Upvotes: 2

Related Questions