Each time I use angular/cli to create a new project by launching the following command
ng new Project-Name
I get the following error
npm ERR! Unexpected end of JSON input while parsing near '...-4","#angular/common"'
I tried to force clean the cache and re-try but still face the same problem.
NodeJS version: 12.16.3
npm version: 6.14.4
Angular CLI version: 9.1.4
OS: Windows 10 Home win32 x64
Edit: All the commands above I run them in Powershell as administrator
This is not a definitive answer but it looks like your global packages are corrupted in some way.
This bug may be caused by many different things. I suggest doing the following.
Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. This is enough for angular 9 and from my experience it is the most stable version for development. This should also change your NPM version so that may also help.
Uninstall global angular package npm uninstall -g #angular/cli
Force clear cache npm cache clean --force
Just to double check npm cache verify
You can also try clearing your %temp% and %roaming% AppData/npm-cache
install latest angular package npm install -g #angular/cli#<your-version>
if this error still occurs, consider using another shell
If this don't solve the problem try to manually locate the package.json file that is throwing an error and investigate.
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?
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
Try to clean the npm cache using:
npm cache clean --force
then should it works now,
ng new my-app
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.
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
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.
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!
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!
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.
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
npm install --global yarn
yarn global add #angular/cli
ng config -g cli.packageManager yarn
ng new projectname
this will fix the issue..
npm uninstall -g #angular/cli
npm cache clean --force
npm install -g #angular/cli
then should it works now,
ng new my-app
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
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
Only solution worked for me
Clear NPM cache + uninstall node
Install Node.js
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.
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.
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 .
Always update to the latest LTS version of Nodejs before using angular cli current version.
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
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"
}
}
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
This must work because I had a similar problem
npm install -g #angulat/cli
npm install mkdirp
npm cache verify
close terminal and open again
ng new your project name
if it doesn't work, turn your firewall off and do them again. I bet it will work.
I had the same problem, this command resolved my problem:
ng config -g cli.packageManager yarn
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
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.
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.
Please install new node js updated version and angular CLI as well.
will surely solve your problem.
npm cache clean --force
ng new my-app --skip-install
cd my-app
npm i
ng serve
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
I had a similar problem, which I solved like this:
npm install -g npm#latest
npm cache clean --force
ng new project-name
Follow this way to solve this issue
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.
Open a new terminal window, browse to where you want your new project and try the 'ng new` command again.
Hi try all above suggestion clearing the cache, reinnstalling ng, ...
Restarting my server did the trick..
I am trying to create a React App and I am getting the following error in my console.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
yarn add v1.10.1
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning react-scripts > eslint > file-entry-cache > flat-cache > circular- json#0.3.3: CircularJSON is in maintenance only, flatted is its successor.
[2/4] 🚚 Fetching packages...
error eslint#5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "9.5.0"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact react react-dom react-scripts --cwd /Volumes/server2/Desktop/JavaScript/birdcage has failed.
Deleting generated file... package.json
Deleting birdcage / from /Volumes/server2/Desktop/JavaScript
Done.
I have tried brew upgrade node but that didn't seem to work. Any ideas on how this can be fixed would be greatly appreciated.
One of the temporally fix is to run yarn install --ignore-engines
I was facing the same issue, try to add "--use-npm" at the end of create react app commend.
create-react-app appname --use-npm
I had the same problem, simply doing this solved the problem:
npm install node#latest
Try to uninstall yarn and install it via npm.
npm i create-react-app -g
create-react-app yourappname
Make sure that node is installed!
I had the same problem, try it:
yarn config set ignore-engines true
I re-installed node and updated xcode developer tools. Also, re-installed React on that computer which is running Mojave.
Assuming nvm is installed, use it to see which version of node you're using, then use it to change to a later version.
you can change the version with nvm use <version> and then try again
In my Ubuntu 18.04 had a native version from the OS installed that not listed by NVM.
I removed it and then I ran:
Firstly run, nvm install 14.5.0
then run, nvm use 14.5.0
And the installation completed properly.
i had same issue when i was adding router plugin to vue-cli with npx and yarn as well..
In pyhton virtual environment i have updated node version from 8.x.x to 16.x.x and used command nvm use 16.x.x but still problem persists .. i was actually executing command as root .. so nvm is using node version as 8.x.x only ..
after long time i realised executing command with sudo was the issue and then executed as a normal user...
this solution worked for me !!!
As the warning said, I updated node via nvm to the version required. For me having the latest node lts version was enough.
nvm install "lts/*" --reinstall-packages-from="$(nvm current)"
But even after upgrading node, yarn still gave the error.
The problem was npm was still executed from the old .bin path of previous node version. nvm also installs latest version of npm in respective local .bin folder for the node version installed.
I used the following commands then,
nvm install-latest-npm: Attempt to upgrade to the latest working npm on the current node version
nvm install --latest-npm: After installing, attempt to upgrade to the latest working npm on the given node version
After this, it worked properly.
Reference:
How can I change the version of npm using nvm?
I'm working on a club project and we are using angular for our platform, I'm just doing front-end homepage stuff, so technically I just use the angular stuff to run and test.
It was working fine but now everytime I run ng build --watch I get this error:
C:\Users\User\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\ember-cli\lib\ui\index.js:56
this.outputStream.write(data);
^
TypeError: Cannot read property 'write' of undefined
at UI.write (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\ember-cli\lib\ui\index.js:56:23)
at UI.writeLine (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\ember-cli\lib\ui\index.js:69:8)
at Watching.callback [as handler] (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\tasks\build.js:44:29)
at Watching._done (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:106:8)
at compiler.emitRecords.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:79:19)
at Compiler.emitRecords (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:371:38)
at compiler.emitAssets.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:62:20)
at applyPluginsAsyncSeries1.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:364:12)
at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:218:11)
at Compiler.compiler.plugin (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:220:14)
at Compiler.compiler.plugin (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#ngtools\webpack\src\plugin.js:326:13)
at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:220:14)
at callback (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\copy-webpack-plugin\dist\index.js:126:17)
at Compiler.afterEmit (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\copy-webpack-plugin\dist\index.js:220:13)
at Compiler.applyPluginsAsyncSeries1 (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:222:13)
I'm totally lost around this, I've tried multiple threads to reinstall node and angular and nothing.
I've followed this one in particular: How to uninstall Angular CLI? .
The weirdest part is now when I try to do this on ubuntu by cloning the project, setting the env variables and do npm install, every time I do ng watch build it gives me the same error. But apparently, I'm the only one on the team.
It's because of the new Angular version. Go with the old Angular version:
npm uninstall -g #angular/cli
npm install -g #angular/cli#6.0.8
Seems to be caused by latest version of Angular CLI (released today). I worked around it by installing previous version (6.0.8) globally.
Update:
As per prionp answer below:
Angular CLI v6.1.2 fixed the issue.
Update your version :
npm update -g #angular/cli
I have tried to install angular(version 6.1.1 and 6.1.0 and 6.0.9). unfortunately, I have faced error in all of mentioned versions. But, I could install angular 6.0.8 successfully.
try this command in your console:
npm uninstall -g #angular/cli
npm install -g #angular/cli#6.0.8
Angular CLI v6.1.2 fixed the issue.
Update your version :
npm update -g #angular/cli
Faced the same issue, its related to both 6.10 and 6.11, one option is to downgrade your #angular/cli to 6.0.8 or to update the local #angular/cli manually
Change #angular/compiler-cli version in your package.json, to the same version as #angular/core and the others.
And then, run an npm update to get the updated version.
When I try to install ExpressJS with the command npm install -g express, I get the following errors:
What can I do about it?
I assume node -v gives 0.10.something.
Get rid of it and install a newer version of node from nodejs.org. Also try removing node_modules and npm install everything again.
Actually, I fixed the problem by uninstalling the latest version and installing the currently recommended one for most users - version 6.9.1.
The cause of the problem still remains unknown.