Related
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 know there are lot many question regarding this npm package installing but I couldn't find the exact relevant answer, I have already installed npm and also developed few applications in my VStudio, Every time before developing the new project of angular do we need to install npm again by typing this in cmd "npm install -g #angular/cli?
Once you have installed #angular/cli globally, in the next project you just need run ng new app-name.
This command will create a folder named 'app-name', than will install all dependencies locally - including #angular/cli.
Installing #angular/cli globally allow you to use 'ng' command everywhere. It's required to install locally because to your project, some specific #angular/cli version is required and newer versions maybe brake.
If your #angular/cli global is newer than the local project version, 'ng' will use the local #angular/cli instead, when you run 'ng serve', for example.
Resume: after installed using npm install -g #angular/cli, you will need just to run ng new app-name.
No. You only need to run
npm i -g #angular/cli
Once ever (or when you update in the future)
And that's used to generate angular apps and different angular cli-related terminal commands. You don't need to run it ever again after that. But you will need to install it locally in your project so that certain things will work propertly
I'm trying to learn Angular and my knowledge in terminal is beginner. After I installed Angular and then type ng new my-project. I get the response ng: command not found. I've seen other posts that had this problem and I've uninstalled and reinstalled npm and ng.
The last step I took was npm install -g #angular/cli#latest then ng new my-project.
Then I get ng: command not found.
Guess You are running on Windows
(To make #jowey's answer more straightforward).
Install Angular normally from your bash $ npm install -g #angular/cli#latest
Next is to rearrange the PATHS to
NPM
Nodejs
Angular CLI
in System Environment Variables, the picture below shows the arrangement.
I had that same problem and just solved it.
make sure you have node installed.
after running
npm i -g #angular/cli
when installation is finished, try re-opening your git bash or whatever you're using or open it in a new folder. boom. it worked for me
The error may occur if the NodeJs is installed incorrectly or not installed at all.
The proper way to fix that is to install/reinstall it the right way (check their official website for that), but if you're searching for a quick solution, you can try to install Angular CLI globally:
npm install -g #angular/cli
If it doesn't work and you are in a hurry, use sudo:
sudo npm install -g #angular/cli
Don't forget to reopen your terminal window.
For MacOS
Sometimes the ng command does not get established as a link in /usr/local/bin. I fixed the problem by adding it manually:
ln -s /usr/local/Cellar/node/10.10.0/lib/node_modules/angular-cli/bin/ng /usr/local/bin/ng
It may has not helped OP, but it solved my problem. This answer is to help others who have not tried the command mentioned in OP's question.
Just use npm install -g #angular/cli#latest. It did the trick for me.
If you have already installed #angular/cli
Then you only need to link it to npm using npm link #angular/cli
Otherwise first install angular by npm install #angular/cli and then link.
if you install npm correctly in this way:
npm install -g #angular/cli#latest
and still have that problem, it maybe because you run the command in shell and not in cmd (you need to run command in cmd), check this out and maybe it helps...
If you are working on Windows then do the following:
From this directory:
C:\Users\ [your username] \AppData\Roaming , delete NPM folder then install Angular using this command npm install -g #angular/cli
*Windows only*
The clue is to arrange the entries in the path variable right.
As the NPM wiki tells us:
Because the installer puts C:\Program Files (x86)\nodejs before C:\Users<username>\AppData\Roaming\npm on your PATH, it will always use version of npm installed with node instead of the version of npm you installed using npm -g install npm#.
So your path variable will look something like:
C:\<path-to-node-installation>;%appdata%\npm;
Now you have to possibilities:
Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…
This will load the npm version installed with npm (and not with node) and with it the installed Agnular CLI version.
If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this:
…;C:\Users\<username>\AppData\Roaming\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
or
…;%appdata%\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
for the short form.
This worked for me since a while now.
Before wasting lots of time in installing and uninstalling, read this.
If you already installed angular before and found this issue, may be it is the reason that you installed angular before with running terminal as Administrator and now trying this command without administrator mode or vice versa. There is a difference in these two.
If you installed angular without administrator mode you can only use angular commands such as ng without administrator mode. Similarly,
If you installed angular with administrator mode you can use angular commands such as ng in administrator mode only.
100% working solution
1) rm -rf /usr/local/lib/node_modules
2)brew uninstall node
3)echo prefix=~/.npm-packages >> ~/.npmrc
4)brew install node
5) npm install -g #angular/cli
Finally and most importantly
6) export PATH="$HOME/.npm-packages/bin:$PATH"
Also if any editor still shown err than write
7) point over there .
100% working
Windows 10 Only
If you are using Git Bash and also you are sure that you have done all steps that are listed above, still getting an error like this, run following command:
alias ng="C:/Users/<your-username>/AppData/Roaming/npm/node_modules/#angular/cli/bin/ng"
then run ng -v
Finally, it works if you see the version of Angular-CLI
I had the same issue in Windows. I could solve it by running the ng command with npm
ng g c test
Error : C:\Users\user\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
Solution :
$ npm run ng g c test
Other solution worked for me to use Windows PowerShell or command prompt instead of bash shell
Most of the time developers install just Node.js and start working on development. This issue related angular cli dependency on your development environment.
You can fix this with command
npm install -g #angular/cli
First of all check by running
npm config get prefix
It should return some thing like (C:\Users\acer\AppData\Roaming\npm)
if it does not return it.
run npm config delete prefix
then run npm install -g #angular/cli#latest
And check by running ng --version
It has solved my problem. Hope it will help you.
**
if you have npm, install run the command
npm install -g #angular/cli
then bind your ng using this:
cd
alias ng=".npm-global/bin/ng"
Follow the Pictures for more help.
Removing NODE and using NVM instead fixed a lot of issues.
removing Node from your system
install NVM from here https://github.com/creationix/nvm
Install Node via NVM: nvm install
stable run npm install -g angular-cli
LINK
Step 1 : Delete "npm" folder from the following path
C:\Users\YourUserName\AppData\Roaming
Step 2 : Once you have the "npm" folder deleted, uninstall Node.Js.
Step 3 : Reinstall Node.JS
Step 4 : Install Angular CLI Using this command npm install -g #angular/cli#latest
Step 5: Now try : ng --version or ng -v
I had a lot of issues installing it on a mac with all the permission errors
Finally the following line solve the issue.
sudo npm i -g #angular/cli
>> npm uninstall -g angular-cli
>> npm uninstall -g #angular/cli
>> npm cache clean
Restart you machine
then >> npm install -g #angular/cli#latest
set Path : C:\Users\admin\AppData\Roaming\npm\node_modules#angular\cli
Hope you never get 'ng' not found
I tried this and everything worked by changing the npm directory.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
npm install -g jshint
ng --version
You can install npx to use Angular CLI installed in your directory:
npm install -g npx
npx ng serve
You must know the full path of your angular installation.
For example: C:\Users\\AppData\Roaming\npm\node_modules#angular\cli\bin\ng .
Type in cmd, powershell or bash
alias ng="C:\Users\<your username>\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng"
In my case
OS Version: Ubuntu 18.04.4 LTS
Node version v12.16.0
Remove ng from /usr/local/bin by using below command.
sudo rm -r ng
After that, installed ng by using command mentioned below.
sudo npm install -g #angular/cli
For Linux user
$ alias ng="/home/jones/node_modules/#angular/cli/bin/ng"
then check angular/cli version
ng --version
enter image description here
alias ng="C:/Users/<user_name>/AppData/Roaming/npm/node_modules/#angular/cli/bin/ng".. This did work..
Happy Coding :)
I guess everyone figured this out years ago but me. simple ng stopped working when I updated node. I tried all the previous suggestions in this thread to no avail but this is my solution. the command npm ng works but darn it I want just ng to work. So
I created a bat filed named ng.bat with this content
npm ng %*
either put ng.bat in a directory recognized by path or add a new path in This Computer / Properties / Advanced System Settings / Environment Variables/ System Variables / Path . For instance I added C:\Shortcuts to path.
EDIT the above answer is not THE REAL SOLUTION. What npm need is to find the npm-cli.js which is located in the npm bin directory. If a path is not set to bin then not work. I just copied npm-cli.js and put it in the npm directoy which has a path set to it.
Windows oriented:
If you're chasing an "update node/angular and I wiped my AppData
folder and now the world hates me stream of errors", then this may help.
Clear out Environment Variable settings for Node/npm/#angular/cli (They don't help)
Install Node.JS/npm from https://nodejs.org/en/ (Remember where you install it)
Confirm the location npm is [currently] running from:
npm config get prefix
Realize that is not where you just install new/fresh Node.
Update npm global pointer (which is not an environment variable)
npm config set prefix "C:\Program Files\nodejs"
Reinstall Angular
npm install -g #angular/cli#latest
Check angular install
ng --version
Hopefully this helps someone. Sorry, you'll have to reinstall any other interesting packages.
I'll add this as "yet another option" which worked for me when none of the other options worked( on windows ).
You can run the angular binary via its full path name.
node C:\Users\user\node_modules#angular\cli\bin\ng.js --version
Oddly enough, adding these paths to my env didn't work...for some reason windows opened editor to edit ng.js file instead of running it.
For me the issue was something with node. Version was very wrong somehow.
Uninstalled node from "Add or remove programs" and then re-installed it using the file from their website.
I'm new to node and using npm to both do some node, angular and Express tutorials. I have used bower before in a tutorial. I'm pretty sure I have installed it using -g already as when i run the bower -v command I get back 1.3.3 I am to understand that installing it using -g means, Install this globally so that on the next project I don't have to install it again.
1) Is this correct?
2) When I start working with a new project do I have to initialize bower?
3) Is there any reason I should use install bower --save-dev after I have already installed bower (-g)lobally?
4) What exactly does install bower --save-dev do?
I have searched and get nothing on google or stack over flow when I search "--save-dev".
I really want to understand this and if you help me, it will help me understand installing much more than just bower and how to use those installs. Again, I'm new to the command line for this type of development and new to these technologies, but have some basic understanding.
Using the --save and --save-dev flags when installing will add them to the project's package.json. This allows anyone who might develop on or use the project to install the dependencies as needed with a simple npm install command. By contrast, the -g flag is global only to your local machine.
I've installed NVM for node.js using the instructions from this post:
http://www.backdrifter.com/2011/02/18/using-nvm-and-npm-to-manage-node-js/
When I switch between node versions and then use npm to install a module, all the modules are placed in the same 'node_modules' folder (~/node_modules/) instead of in the 'node_modules' directory specific to that version of node?
Any idea on how to remedy this?
Based on the comments from https://github.com/creationix/nvm/pull/97:
When installing packages with npm using the global switch -g the
package ends up in the proper directory (i.e.
.nvm/$VERSION/lib/node_modules), however node is unable to require it
since it somehow isn't searching on it's prefix.
So using npm install -g xxxxx will put the modules in the correct location for NVM but if you try to require one of them node can't find the module. I am still playing around with this and will update if I find a solution.
Update
Where does NPM put node_modules? (see https://docs.npmjs.com/files/folders)
Local install (default): puts stuff in ./node_modules of the current package root.
Global install (with -g): puts stuff in /usr/local or wherever node is installed.
Install it locally if you're going to require() it.
Install it globally if you're going to run it on the command line.
If you need both, then install it in both places, or use npm link.
So what I did was run npm init (see http://npmjs.org/doc/init.html) in my projects root dir which generated package.json. Now when I run npm install xxxxx it creates a node_modules dir in my project folder (which I add to my .gitignore). This works for modules that I require in my code.
For commands such as CoffeeScript I install with npm install -g coffee-script which puts it in the correct directory (.nvm/$VERSION/lib/node_modules). While I can't require these modules (npm link should solve this problem) I can run the commands - i.e. coffee.
I just installed express globally (-g) and was having problem when require("express"). Just like Jesse Vogt said I just reinstalled express but this time without the -g just like this: "sudo npm install express" and now is working perfectly!
For latest nvm window version 1.1.7.
Package was installed and placed into the respective nodejs version.
nvm use 16.8.0
npm install truffle
nvm use 16.7.0
npm install mysql