35

I have angular 9 installed

Angular CLI: 9.0.1 Node: 13.8.0 OS: win32 x64

Angular: ... Ivy Workspace:

Package Version

@angular-devkit/architect 0.900.1
@angular-devkit/core 9.0.1
@angular-devkit/schematics 9.0.1
@schematics/angular 9.0.1
@schematics/update 0.900.1
rxjs 6.5.3

Everytime i try to create a new project with ng new, I'm getting the message

Installing packages...npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! Unexpected end of JSON input while parsing near '...pm-signature":"-----B' npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Lijo John Daniel\AppData\Roaming\npm-cache_logs\2020-02-12T09_52_57_342Z-debug.log × Package install failed, see above. The Schematic workflow failed. See above.

I have tried re-installing angular and even node but issue still remains

My OS version is Win 10 v.1909 build 18363.592. Can someone help me with this?

Lijo Daniel
  • 371
  • 1
  • 3
  • 7

31 Answers31

25

First ,verify your NPM cached memory

npm cache verify

then try :

npm cache clean --force
npm install –g @angular/cli@latest 
ng new <YourProjectName>

If the problem persists, then try the following

npm cache clean --force
npm update
ng new <YourProjectName>
NOTE
As @0210vidit said in the comment below:

do not use dash(-) or (.) in naming

Abolfazl Roshanzamir
  • 12,730
  • 5
  • 63
  • 79
15

Try to clean the npm cache using:

npm cache clean --force

then should it works now,

ng new my-app
Mahrez BenHamad
  • 1,791
  • 1
  • 15
  • 21
8

I had similar issue and installing yarn or clearing cache didn't help. I removed '-' from my app name and it worked

Error :

ng new first-app

Solved:

ng new firstapp

Hope it helps.

0210vidit
  • 59
  • 1
  • 4
6

This issue is reported for angular 9 and multiple geo-locations are facing this problem. refer https://github.com/angular/angular-cli/issues/16944

to proceed you can bring you angular version to 8 with below steps

ng --version

npm uninstall -g @angular/cli

npm cache clean --force

npm install -g @angular/cli@8.0.0

ng --version

smalvank
  • 61
  • 3
5

I had this issue since yesterday, tried all of this and it did not work. Then I installed yarn, and configured angular cli to use yarn as the packagemanager by running this command ng config -g cli.packageManager yarn, and it worked.

CodeNaj
  • 51
  • 1
  • got this error: Error: Schema validation failed with the following errors: Data path "/cli" must NOT have additional properties(completion). – Zaffer Jun 12 '22 at 20:26
3

First try the following

npm cache clean --force
npm install -g @angular/cli
ng new <project-name>

If the problem persists, then try this (this eventually solved my workflow issue)

npm cache clean --force
npm update
ng new <project-name>

Thanks!

Akhil
  • 368
  • 4
  • 16
3

In my case i've tried everything with npm and no way out.

But with yarn worked with no worries!

I'm a windows user but you can find how to install in other OS in yarn website!

1st - i downloaded yarn from his website yarn

2nd - installed the global package with vs terminal: yarn global add @angular/cli

3rd - still in vs terminal set: ng config -g cli.packageManager yarn

4th - i created my app: ng new myapp

5th - so you know te rest ...

Worked fine to me!

3

I removed my previous solution as I somehow got hung up on the uninstalled node_modules part and presented a solution that probably wouldn't have been relevant. Here is an alternate solution that might work for you...

Open a new terminal and run node -v and then npm -v to make sure you are running compatible versions: "Node 8.9 or higher, together with NPM 5.5.1 or higher" Uninstall your current Global Angular cli npm uninstall -g @angular/cli Run npm cache verify Re-Install Angular CLI npm install -g @angular/cli@latest Close your terminal window (just because). Open a new terminal window, browse to where you want your new project and try the 'ng new` command again.

3

This work fine top of all solutions and worked for me on Windows 10... Go to vs code new terminal type the following in order

  1. npm install --global yarn
  2. yarn global add @angular/cli
  3. ng config -g cli.packageManager yarn
  4. ng new projectname

this will fix the issue..

2
  1. npm uninstall -g @angular/cli
  2. npm cache clean --force
  3. npm install -g @angular/cli

then should it works now,

ng new my-app
Akitha_MJ
  • 3,882
  • 25
  • 20
1

I got it working, first I installed angular 8 then ran npm install -g @angular/cli@latest. It updated to angular 9 and now i'm able to create new projects. Thank you all for your consideration

Lijo Daniel
  • 371
  • 1
  • 3
  • 7
1

Angular 9 ng new myapp gives error The Schematic workflow failed......

Firstly, uninstall Angular: npm uninstall -g @angular/cli

After uninstall, you should do clean Angular cache: npm cache clean --force

After this, you should do re-install Angular globally: npm install -g @angular/cli

And check the version: ng --version

Now you can create your app: ng new your-app

Tomislav Stankovic
  • 3,080
  • 17
  • 35
  • 42
1

Only solution worked for me

  1. Clear NPM cache + uninstall node

  2. Install Node.js

  3. Install Angular CLI

This will cost you some Internet data, but better option than wandering around for nothing! Keep a back up of Node.js. Useful next time.

David Buck
  • 3,752
  • 35
  • 31
  • 35
A.K.J.94
  • 492
  • 6
  • 14
1

Here is the simple way, i am sure it will help because this is the error with package installation failed.

Skip node packages for now and use this command to create new app.

ng new YourAppName --skip-install

after that just go into your project directory and run npm install it will install all required packages for you.

Saad Abbasi
  • 745
  • 11
  • 25
1

I struggled with this type of issue for a while.

Adding the following environment variable to your user account should solve the issue, adding a temporary cache option.

  • name: npm_config_cache
  • value: /tmp/empty-cache

More information concerning npm-config .

Jean-Louis
  • 11
  • 2
  • 1
    I've had this issue because of not having Git installed – Nick Gallimore Aug 28 '20 at 17:19
  • My experience was pointing to a npm install cache issue (credit to [infin80](https://stackoverflow.com/users/256509/infin80) and to [this post](https://stackoverflow.com/a/54100103/14183500) for teaching me about using the --cache option). To solve the npm install issue I had during the creation of a new angular app, I found that the environment variable npm_config_cache was setting the option transparently. – Jean-Louis Aug 29 '20 at 20:09
1

Always update to the latest LTS version of Nodejs before using angular cli current version.

Krishnadas PC
  • 5,981
  • 2
  • 53
  • 54
0

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

Abdel Ali
  • 31
  • 3
0

I had this issue then I navigate to the file .angular-config path C:\Users\username and change "packageManager" : "npm"

{ "version": 1, "cli": { "analytics": "_________", "packageManager": "npm" } }

0

I had the same problem, after a lot of search and two day of trying many ways, I finally solved my problem by installing codelyzer. first run this command in cmd:

npm install -g codelyzer

then run:

ng new yourProject
Suraj Kumar
  • 5,547
  • 8
  • 20
  • 42
  • hello @Maryam, It is nice that you get your solution but it will help us if you can `post the source` from where your problem is solved, thanks. – vaku Mar 22 '20 at 12:21
0

This must work because I had a similar problem

  1. npm install -g @angulat/cli
  2. npm install mkdirp
  3. npm cache verify
  4. close terminal and open again
  5. ng new your project name

if it doesn't work, turn your firewall off and do them again. I bet it will work.

Basel Issmail
  • 3,847
  • 7
  • 20
  • 36
0

I had the same problem, this command resolved my problem:

ng config -g cli.packageManager yarn

Matt D
  • 3,289
  • 1
  • 15
  • 29
  • Please don't add _"thanks"_ as answers. They don't actually provide an answer to the question, and can be perceived as noise by its future visitors. Once you [earn](http://meta.stackoverflow.com/q/146472) enough [reputation](http://stackoverflow.com/help/whats-reputation), you will gain privileges to [upvote answers](http://stackoverflow.com/help/privileges/vote-up) you like. This way future visitors of the question will see a higher vote count on that answer, and the answerer will also be rewarded with reputation points. See [Why is voting important](http://stackoverflow.com/help/why-vote). – Yunnosch Apr 30 '20 at 06:28
0

Follow this way to solve this issue

  1. Open a new terminal and run node -v and then npm -v to make sure you are running compatible versions: "Node 8.9 or higher, together with NPM 5.5.1 or higher"
  2. Uninstall your current Global Angular cli npm uninstall -g @angular/cli
  3. Run npm cache verify
  4. Re-Install Angular CLI npm install -g @angular/cli@latest
  5. Close your terminal window.
  6. Open a new terminal window, browse to where you want your new project and try the 'ng new` command again.
Sathiamoorthy
  • 8,831
  • 9
  • 65
  • 77
0

This issue arises mostly because of the npm cache still keeping this error. All you need to do is to force clean the npm cache and try creating your app again.

npm cache clean --force
ng new myapp
Faouzi
  • 49
  • 7
0

I got the same error. Before you reinstall the Angular CLI you have to check your internet connection and its speed. In my case, the error has occurred because my internet connection was interrupting. I could resolve that issue after I fixed my connection issue.

0

Ensure cli is in a small case and package looks like @angular/cli during installation. I have followed this in some tutorial to solve this issue.

Shankar Ganesh Jayaraman
  • 1,401
  • 1
  • 16
  • 22
Omar Hegazi
  • 122
  • 1
  • 6
0

Please install new node js updated version and angular CLI as well. will surely solve your problem.

0
  1. npm cache clean --force

  2. ng new my-app --skip-install

  3. cd my-app

  4. npm i

  5. ng serve

0

I got this error when updating npm to 7.x.x

So if you want to use angular12 based on angular-cli-node-js-typescript-compatiblity-matrix version of node and npm should be like this :

node : 12.13.x - 14.15.x npm : 6.x.x - 7

I used nvm for mange version of node

Mohammad Yaser Ahmadi
  • 4,664
  • 3
  • 17
  • 39
0

I had a similar problem, which I solved like this:

npm install -g npm@latest
npm cache clean --force
ng new project-name
Avius
  • 5,504
  • 5
  • 20
  • 42
Cassey
  • 1
  • 1
    Hi Cassey, welcome to SO! A short comment about the script and how it addresses the problem would be great. – Avius Jun 25 '21 at 12:10
0

Hi try all above suggestion clearing the cache, reinnstalling ng, ... Restarting my server did the trick..

123pierre
  • 305
  • 1
  • 4
  • 18
-1

I followed this link and got my issue resolved.

You can also follow this link. This also resolves the issue.

in the short first link says:

npm cache clean --force npm i -g @angular/cli

the second link says:

ng new angular --skip-install cd angular npm i ng serve