I'm getting into trouble with anngular-cli installation because it doesn't recognize the ng command in my git bash but it works in my cmd on Windows 7.
I looked for some issues on the web but I didn't really find a solution.
Here, the error :
ng -v
module.js:549
throw err;
^
Error: Cannot find module 'C:\Program
Files\Git\node_modules\#angular\cli\bin\ng'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
This error happened the first time I used ng after installing Node and angular-cli globally.
I didn't get this error when I was working on my laptop on Windows 10.
Problem:
Error: Cannot find module
'..\AppData\Roaming\npm\node_modules\angular-cli\bin\ng' angularJs
Solution:
uninstall angular cli if you have already installed it
npm uninstall -g #angular/cli
Delete the C:\Users\Satish\AppData\Roaming\npm\node_modules#angular folder if it still exists after the uninstall
reinstall angular-cli globally
npm install -g #angular/cli
First, uninstall the angular cli using
npm uninstall -g #angular/cli
Then delete the "NPM" and "Npm-cache" folder under "Roaming" folder.
Now again install the Angular cli using
npm install -g #angular/cli
It worked for me only by removing npm and npm-cache folders from AppData then running :
npm uninstall -g #angular/cli
Then running :
npm install -g #angular/cli
In my case, i fixed it simply just by renaming my project folder.
before : "d/Gdrive/Sem 6 & 7/[project name]"
after : "d/Gdrive/Sem 67/[project name]"
So i guess u may not put special characters in your folder name.
Looks like a dependency was removed somewhere. I worked around this by:
For local angular-cli: npm install #angular-devkit/core --save-dev
For global angular-cli: npm install -g #angular-devkit/core
Edit: As discussed below, you should perhaps not use --save-dev here.
Remove existing angular
npm uninstall -g #angular/cli
and Install
npm install -g #angular/cli --force
reinstall node_modules
git clean -dfx
npm i
if persist, use yarn install first, then repeat above
The git bash is installed in C:\Program Files\Git where you never find the node_module folder that's why this error occurred
When you hit ng command from CMD it will look node_module folder in C:\Users\uername\AppData\Roaming\npm\ - where npm install global dependency and eventually it finds node_modules folder.
Basically for windows try to run from cmd.
In my case the problem is
npm ERR! code EEXIST
npm ERR! path C:\Program Files\nodejs\node_modules\#angular\cli\bin\ng.js
npm ERR! dest C:\Program Files\nodejs\ng
npm ERR! EEXIST: file already exists, cmd shim 'C:\Program Files\nodejs\node_modules\#angular\cli\bin\ng.js' -> 'C:\Program Files\nodejs\ng'
npm ERR! File exists: C:\Program Files\nodejs\ng
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<UserId>\AppData\Roaming\npm-cache\_logs\2022-01-03T20_13_43_709Z-debug.log
Solution:
I use this comment of npm 5 line on the shell
$ npm ERR! File exists: C:\Program Files\nodejs\ng
Delete the file ng and run:
npm install -g #angular/cli
And Done!
I faced the same problem but running npm install solved my problem.
I had this error in Angular Console starting with release 11.
I was missing a locale cli. So
npm install #angular/cli
solved my problem
It might be an issue with the package installation. Sometimes the installation might brake due to network issues. Also the access permission affects the installation.
So, try to install the package by running command prompt (CMD) as Run as administrator.
Follow the steps to resolve the issue.
1.Run CMD as Run as administrator mode.
2.Uninstall angular cli.
npm uninstall -g #angular/cli
3.Remove npm package files from the appdata folder.
Open Run option by pressing Windows + R key. Then type %appdata% and press OK.
Open the npm folder from the Roaming folder that you got in the explorer.
Delete ng and ng.cmd files from the npm folder if exists.
Open node_modules folder from there and delete #angular and angular/cli folder if exists.
4.Reinstall the angular cli
npm install -g #angular/cli
npm install --legacy-peer-deps
npm cache clean --force
If the environment variable path is properly set , please run ng in an angular project otherwise it will keep showing that error
once you run npm uninstall -g #angular/cli, check if there is an error in the console, it is usually a message with red line says "err!", mine said that it was unable to delete a file , follow the path of the file and delete manually ,then run npm uninstall -g #angular/cli and npm uninstall #angular/cli, when it goes successfully , run npm install -g #angular/cli , that should fix it.
If most suggested and obvious solution below do not work
npm uninstall -g #angular/cli
remove roaming -> npm
npm install -g #angular/cli
Try to upgrade Node.js version. This solved the problem in my case after severl hours of investigation
Try deleting the node_modules folder (not the AppData one), the one in your project folder, and try reinstalling angular again.
If you have MAC(Mackbook) pc use brew command because we can not install angular-cli from npm command
brew install angular-cli
Related
Running Windows 10 Enterprise.
I am trying to install angular cli to run the angular project. I entered below command.
--> npm install -g #angular/cli
I m getting below error.
--> npm ERR! code ENOVERSIONS
--> npm ERR! No valid versions available for undefined
what am i doing wrong
Seems to be you have to uninstall the node version and have to install it again
In order to run the npm install -g #angular/cli You need to have the node installed. Please find the below link to install the relevent node version for your PC. And try running the npm install -g #angular/cli command again.
Download the Node.js
Please make sure old node_modules are completely deleted and package-lock.json . Try fresh npm install now
rm package-lock.json
rm -rf node_modules
npm install
I'm trying to to upgrade npm packages via
npm update -g
But, I get this error:
npm ERR! path C:\Program Files\nodejs\npm
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Program Files\nodejs\npm: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm
npm ERR! Move it away, and try again.
I've googled but none of the solutions work. One sadi to remove the npm.cmd and npm files from here:
C:\Program Files\nodejs\
I tried that, but it fails as npm is now missing.
That folder, C:\Program Files\nodejs\, is actually a shortcut pointing to
C:\Users\lthurman\AppData\Roaming\nvm\v8.11.1
I'm using nvm to manage my node installations, any ideas on how to fix this?
Thanks
To resolve this issue I took the following steps
Where [userName] is your Windows user name -- [nodeVer] is your current version of Node, or the one that is giving you issues using NVM
Delete these four files:
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npm
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npm.cmd
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npx
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npx.cmd
Then in C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\node_modules\, rename the npm directory to npm_old
Open up your console of choice -- run as admin if necessary -- and navigate into the \npm_old\bin directory then install NPM at latest (or replace latest w/a version of your choosing) using the command below:
node npm-cli.js i -g npm#latest
Clean-up by deleting the npm_old directory from earlier. Now all should be good to go...I hope!
Try doing this below command after deleting the folder C:\Users\xxx\AppData\Roaming\npm, C:\Users\xxx\AppData\Roaming\npm-cache.
npm install -g npm#latest
It will fixed it by forcing the install with --force
npm install -g npm#latest --force
Uninstall old version first
npm uninstall -g your-package-name
install the latest
npm install -g your-package-name#latest
I'm using nvm-windows version 1.1.7.
I just installed node 11.9.0.
nvm installs npm version 6.5.0 together with this node version.
However, there's npm version 6.7.0 available already.
When I now do npm i -g npm I get:
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Move it away, and try again.
I found no way to avoid this.
This is a duplicate from my answer here: https://stackoverflow.com/a/50955293/491553
Here is how I upgrade npm when running nvm-windows:
cd %APPDATA%\nvm\v14.20.0 # or whatever node version you're using
move npm npm-old
move npm.cmd npm-old.cmd
move npx npx-old
move npx.cmd npx-old.cmd
cd node_modules\
move npm npm-old
cd npm-old\bin
node npm-cli.js i -g npm#latest --force
And boom, upgraded.
Several workarounds are available in this Issue on the nvm-windows github repo:
https://github.com/coreybutler/nvm-windows/issues/300
There are examples using DOS, PowerShell, bash, and batch scripts.
I have windows 10 operating system.
I installed in following way.
cd %APPDATA%\nvm\v8.11.3
move npm 5.6.0
move npm.cmd 5.6.0.cmd
cd node_modules\
move npm 5.6.0
cd 5.6.0\bin
node npm-cli.js i -g npm#latest
I had to force it :-/
When it came to
node npm-cli.js i -g npm#latest
I'd rather had to use
node npm-cli.js i -g npm#latest --force
probably to overcome a permission error involved in overwriting the "C:\Program Files\nodejs" link.
download this updateNpm.bat file
open powershell in that same folder and run this command updateNpm.bat latest
I tried the script and other solutions, this by far is the easiest way:
Navigate to the relevant Node folder (cd C:\Users\yourUser\AppData\Roaming\nvm\vxx.xx.x)
rename npm -> npm2
rename npm.cmd -> npm2.cmd
rename npx -> npx2
rename npx.cmd -> npx2.cmd
Run npm2 install -g npm#your-version
the new npm will create npm, npm.cmd, npx, npx.cmd files, so you can remove the previous renamed files
I also found it necessary to install windows-nvm to c:\nvm and c:\nodejs to prevent issues with unsupported paths with spaces.
rm C:\nodejs\npm*
rm C:\nodejs\npx*
mv C:\nodejs\node_modules\npm C:\nodejs\node_modules\npm-old
node C:\nodejs\node_modules\npm-old\bin\npm-cli.js i -g npm#next
For me I only get the problem when updating npm with npm v6.
So using a newer version of npm via npx to run the upgrade works for me.
For the very newest version
npx npm install -g npm
Or use a specific version
npx npm#7 install -g npm#7
I faced this problem today, the way i solved it was installing latest node with nvm then copying the npm files from latest to the version i am on.
nvm install latest
cd AppData/Roaming/nvm/LATEST
xcopy npm.cmd ../LTS && xcopy npm ../LTS && xcopy node_modules/npm ../LTS
I then confirmed it working by trying to compile my code that breaks on latest.
This worked for me:
curl -L https://npmjs.org/install.sh | sh
If you already have git bash installed, use it there.
I installed the latest Node and Angular on Windows 10
npm install npm#latest -g
npm install -g #angular/cli#latest
But when I try to start a project ng new new-project I get the following error
npm WARN tarball tarball data for #angular/compiler#^6.1.0 (sha512-TY6axB1c7VvYXf+ebFDq3Ej+edgii3CDxew8HnyTFAWeDF2Gh8io1vTYwtdyDka6U53ASaheM1HpiUjzvYH0jQ==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\admin\Desktop\...\node_modules\.staging\#angular\common-6be83a81\locales\si.js'
...
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2018-10-08T01_01_48_404Z-debug.log
Package install failed, see above.
I tried to uninstall Node.js and Angular CLI completely and then reinstall again
npm install npm#latest -g
npm install -g #angular/cli#latest
But still the same error ..... So I googled this issue. It seems like some people had it too, but then it magically disappeared for some people.
How to fix this?
I was getting the same below error when attempting to a create new project using ng new command.
npm WARN tarball tarball data for #angular/compiler#~7.2.0
(sha512-5yb4NcLk8GuXkYf7Dcor4XkGueYp4dgihzDmMjYDUrV0NPhubKlr+SwGtLOtzgRBWJ1I2bO0S3zwa0q0OgIPOw==)
seems to be corrupted. Trying one more time.
I tried many things but what did not worked and what finally worked for me I have listed below. My working node version is 12.2.0 and npm version is 6.9.0 (i.e. latest version).
What did not worked:
Downgraded node js to other lower versions (tried many version)
Deleted package-lock.json file from project and executed npm install
Executed npm install --registry https://registry.cnpmjs.org instead of npm install
Deleted npm and npm-cache folders from AppData\Roaming and then again installed node js
Deleted node_modules folder, executed npm update and then executed npm install
Executed npm cache clean --force and then executed npm install
Reinstalled #angular/cli
Checked for any firewall / antivirus (in my case it was disabled)
Opened node command prompt as an administrator
Checked user permissions for the project folder
Finally what worked is:
Installed the component for which it was giving error. npm install -global #angular/compiler
I had the same problem with node 12.13.0 and npm 6.13.0
npm WARN tarball tarball data for #angular/compiler#^7.2.11 (sha512-5yb4NcLk8GuXkYf7Dcor4XkGueYp4dgihzDmMjYDUrV0NPhubKlr+SwGtLOtzgRBWJ1I2bO0S3zwa0q0OgIPOw==) seems to be corrupted. Trying one more time.
For me the problem was npm. After upgrading npm to the newest version with npm i -g npm#latest the problem vanished. So it seems to be a problem with npm itself and not the Angular/CLI.
upgrade your NPM version use this command i -g npm#latest it works like magic
I've tried several times to uninstall my angular-cli in order to update it but even if I follow the instructions provided on github:
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#latest
When I check using the command ng --version I still get the old version :
angular-cli: 1.0.0-beta.26
node: 7.7.1
os: darwin x64
How can i fix this issue? Thanks
I have also faced the same issue in recent past for me I have do the following commands one by one in terminal.
sudo npm uninstall -g angular-cli
sudo npm cache clean
After this run
ng -v
If still get angular-cli version 1.0.0-beta.2x.x then run the following command
which ng
It will show the ng path. Go to the path and if it is linked with any file remove the same the link and actual ng file. In my case the link is in /usr/bin/ng and actual path of ng file is /lib/node_modules/#angular/cli/bin/ng.
sudo rm -rf /lib/node_modules/#angular/cli/bin/ng
sudo rm -rf /usr/bin/ng
Next you need to install #angular/cli using
sudo npm install -g #angular/cli
Close all the terminal and run ng -v and you are on. May be it will help someone. Thanks :)
If you are facing issue with angular/cli then use the following commands:
npm uninstall -g angular-cli to uninstall the angular/cli.
npm cache clean to clean your npm cache from app data folder under your username.
use npm cache verify to verify your cache whether it is corrupted or not.
use npm cache verify --force to clean your entire cache from your system.
Note:
You can also delete by the following the paths
C:\Users\"Your_syste_User_name"\AppData\Roaming\npm and C:\Users\"Your_syste_User_name"\AppData\Roaming\npm-cache
Then use the following command to install latest angular/cli version globally in your system.
npm install -g #angular/cli#latest
To get more information visit github angular-cli update.
Updating Angular CLI
https://github.com/angular/angular-cli#updating-angular-cli
If you're using Angular CLI 1.0.0-beta.28 or less, you need to uninstall angular-cli package first.
npm uninstall -g angular-cli
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#latest
Then when it gets done successfully you may try:
ng --version
This sometime happens when you had actually installed #angular/cli using yarn and not npm.
You can verify this by looking in to yarn's global install folder.
You can remove it from yarn using
yarn global remove #angular/cli
You are using the beta version of angular CLI you can do this way.
npm uninstall -g #angular/cli
npm uninstall -g angular/cli
Then type,
npm cache clean
Then go to the AppData folder which is hidden in your users and go to roaming folder which is inside AppData then go to npm folder and delete angular files in there and also go to npm-cache folder and delete angular components in there.After that restart your PC and type
npm install -g #angular/cli#latest
This worked for me ✌️
I found a solution, first, delete the ng file with
sudo rm /usr/bin/ng
then install nvm (you need to restart your terminal to use nvm).
then install and use node 6 via nvm
nvm install 6
nvm use 6
finally install angular cli
npm install -g #angular/cli
this worked for me, I wanted to update to v1.0 stable from 1.0.28 beta, but couldn't uninstall the beta version (same situation that you desrcibed).
Hope this works
The following approach worked for me:
npm uninstall -g #angular/cli
and
npm cache verify
I had the same problem. This doesn't work:
npm uninstall -g angular/cli
npm cache clean
instead use:
npm uninstall -g # angular/cli
I could not get the angular-cli to go away. I FINALLY figured out a way to find it on my windows machine. If you have Cygwin installed or you are running linux or mac you can run which ng and it will give you the directory the command is running from. In my case it was running from /c/Users/myuser/AppData/Roaming/npm/ng
I had angular-cli version 1.0.0-beta.28.3, and the only thing that worked for me was deleting the angular-cli directly from the global node_modules folder:
cd /usr/local/bin/lib/node_modules
rm -rf angular-cli
After that ng version output was, as expected:
command not found: ng
And I could install the latest angular-cli version:
npm install -g #angular/cli#latest
Hope it helps...
Step 1:
npm uninstall -g angular-cli
Step 2:
npm cache clean
Step 3:
npm cache verify
Step 4:
npm cache verify --force
Note:
You can also delete by the following the paths
C:\Users"System_name"\AppData\Roaming\npm and
C:\Users"System_name"\AppData\Roaming\npm-cache
Then
Step 5:
npm install -g #angular/cli#latest
You have to use (without #)
npm uninstall -g angular/cli
because
If you're using Angular CLI beta.28 or less, you need to uninstall angular-cli package. It should be done due to changing of package's name and scope from angular-cli to #angular/cli https://github.com/angular/angular-cli
Try to update via these steps found in the npm repo for the angular cli.
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#latest
There is also an angular cli migration guide. One other option (more involved) is to start a new project and migrate over by copying and pasting certain files. This can be found here in the "moving into the cli" section of the angular-cli github
Check if you have the hidden folder ".npm" in your Home directory and delete the old angular-cli folder.
While uninstalling Angular CLI I got the same message (as it had some permission issues):
Unable to delete .Staging folder
I tried deleting the .staging folder manually, but still got the same error. I logged in from my administrator account and tried deleting the staging folder again manually, but to no avail.
I tried this (run as Administrator):
npm uninstall -g #angular/cli
npm cache verify
npm install -g #angular/cli.
Then I tried creating the project from my normal user account and it worked.
For those using Windows, I had this issue because :
after running npm uninstall -g # angular/cli, the folder AppData\Roaming\npm were still containing a ng file
this file prevented a complete uninstall of the CLI
I tried then to remove the ng file manually, but for some reasons it was not possible (I did not have the right), even as admin.
The only hack I found was using a 'linux based' command (I used Git bash) as admin and removing this file from command line:
cd AppData/Roaming/npm
rm ng.cmd
For information: this was with the version 6 of the CLI. There is not problem anymore to remove manually this specific file after the update.