I ran
npm config set prefix /usr/local
After running that command,
When trying to run any npm commands on Windows OS I keep getting the below.
Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local'
at Error (native)
Have deleted all files from
C:\Users\<your username>\.config\configstore\
It did not work.
Any suggestion ?
Running this command was my mistake.
npm config set prefix /usr/local
Path /usr/local is not for windows. This command changed the prefix variable at 'C:\Program Files (x86)\Git\local'
To access and make a change to this directory I need to run my cmd as administrator.
So I did:
Run cmd as administrator
Run npm config edit (You will get notepad editor)
Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
Then npm start works in a normal console.
This is occurring because windows is not giving permission to the user to create a folder inside system drive. To solve this:
Right Click
The Folder > Properties > Security Tab
Click on Edit to change Permissions > Select the user and give Full Control to that user.
Sometimes, all that's required is to stop the dev server before installing/updating packages.
I solved the problem by changing windows user access for the project folder:
Here is a screenshot:
http://prntscr.com/djdn0g
Restarting VsCode solved it for me!
I recently had the same problem when I upgraded to the new version, the only solution was to do the downgraded
To uninstall:
npm uninstall npm -g
Install the previous version:
npm install npm#5.3 -g
Try update the version in another moment.
I use Windows 10.
I started the CMD as administrator, and it solved the problem.
Find CMD, right click, and click open as administrator.
I had an outdated version of npm. I ran a series of commands to resolve this issue:
npm cache clean --force
Then:
npm install -g npm#latest --force
Then (once again):
npm cache clean --force
And finally was able to run this (installing Angular project) without the errors I was seeing regarding EPERM:
ng new myProject
In my case, I was facing this error because my directory and its file were opened in my editor (VS code) while I was running npm install. I solved the issue by closing my editor and running npm install through the command line.
I had the same problem, after updating npm. Solved it by re-installing latest npm again with:
npm i -g npm
but this time with cmd running in administrating mode.
i did all this because i suspected there was an issue with the update, mostly some missing files.
I had the same problem when I tried to install the npm package AVA. The solution for me was to delete the node_modules folder and force-clean the npm cache:
rm -rf node_modules
npm cache clean --force
I could then install the npm package without a problem.
for me it was an issue of altering existing folders in node_module, so i nuked the whole folder and run npm install again. it works with no errors after that
Just run cmd as admin. delete old node_modules folder and run npm install again.
The Problem I faced (In Windows Computer)
When I was trying to install a couple of npm packages I got the following error:
npm - EPERM: operation not permitted - while npm was trying to rename a file
Here's my debug snippet for reference, if you've faced the similar problem:
After carefully checking out the answers from other users, I have created a detailed answer for the community
My Solution for the problem
Follow the mentioned steps
Right-click on the project folder
Go to properties -> Security Tab
Select Users -> Edit
In the Permission for Users section, Full control -> Give a check mark in Allow -> OK
Wait for Windows security to apply the new security rules
Click OK
Visualization of the steps
If you follow these steps and try to install npm packages again it will work properly.
Note: It's a best practice to close and open up the command line again to experience the changes
Simplest way
Hope I am not too late for this post but recently even I too got hit by this issue. And also I had no admin rights on my laptop.
Here is the simplest way I fixed the bug.
Locate the file name .npmrc (it will be in C:\Users\<user name>\.npmrc)
Open it and change the path of prefix= to prefix=C:\Users\<user name>\AppData\Roaming\npm
hope it will be helpful..
Happened to me since the folder/file was locked by another process. Used a tool (LockHunter) to terminate that process and it started working again (possible reason).
If you getting this error in an IDE's terminal/commands prompt, try delete node_modules, close IDE, and run the npm install command again.
The time when IDE started but still not completed its analysis of node_modules tree is a tricky moment, when packages installation may fail because IDE still scanning node_modules contents.
This error is caused by different problems try the below one of them will work for you!
try to run npm as Administrator
Run cmd as administrator npm config edit (You will get notepad editor)
Change Prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
The errors went after I disabled my anti-virus (Avast)
Sometimes a simple cache clear like the below would fix it.
npm cache clear
For me the problem come from bash terminal. I change my terminal to powershell and it's ok.
Really easy to resolve
Find this command npm cache clean as a solution to those error in quick and simple way!
I updated my node version to 8.9.4 and ran the necessary install command again from administrator command prompt. It worked for me!
A reboot of my laptop and then
npm install
worked for me!
Running npm commands in Windows Powershell solved my issue.
Try npm i -g npm . NPM version 6.9 is work to me.
Apparently anti-virus software can also cause this error. In my case I had Windows Security's Ransomware Protection protecting my user folders which caused this error.
Windows 10,
Running the IDE (in my case IntelliJ) in administrator mode and executing npm install does resolves the problem.
If no IDE then run CMD in administrator mode and try executing npm install
For those trying to update config
If having trouble updating your npm config, try instead running using the -g flag. This solved the issue on Win 10 for me after trying everything else.
npm config edit -g
I am able to update the config and changes are reflected everywhere. This may be due to running npm in an organizational scope.
I was running create-react-app server. Simply stopped the server and everything worked just fine.
The simpler way to solve this by entering the below command
npm config set cache C:\tmp\nodejs\npm-cache --global
At least I just solved my problem in this way:
Search cmd
Then run as administrator
Then npm i -g expo-cli or npm config set prefix /usr/local
I just solved my problem.
Related
I have followed a tutorial to create a folder that holds all npm globally installed, but I still can't run gatsby command even if I have installed gatsby-cli. What is wrong?
It seems that your environment does not recognize gatsby command.
Try this:
npm install -g gatsby-cli
If the error persists, try to close and reopen the shell, sometimes it caches the previous state.
You can check for further details here.
I am in a bizarre problem, I just updated my Node.js and NPM at the date of 01-Feb-2019. And used the following command-
npm install -g firebase-tools
to install the Firebase CLI
Then on typing either of the code below
firebase login
or
firebase init
it is showing the following error
'firebase' is not recognized as an internal or external command,
operable program or batch file.
Please help me. It has already consumed my two days.
npm install -g firebase-tools -f
Using -f for force install again.
This work for me
Ok. First of all, Bizarre problem has some bizarre solution.
Uninstall your node js and NPM completely.
Then reinstall it, and check, whether it works or not.
Best of Luck
If you are using MS Windows:
Open Start Menu or press Win button on your keyboard.
Type "variables".
Click on "Edit the system environment variables"
Click on "Environment Variables..." button.
In the "System variables" list select "Path" and click on the "Edit..." button under the list.
In the "Edit environment variable" dialog click on the "Browse..." button.
Navigate to the c:\users\<yourusername>\AppData\Roaming\ dir and select the "npm" sub-dir, then click "OK".
In the "Edit environment variable" dialog click "OK".
In the "Environment Variables" dialog click on "OK".
For the Linux users:
Navigate to the home_dir.
Edit the hidden ".bash_profile" file.
Add line with following text "export PATH="$PATH:/usr/local/bin".
add to .bash_profile
export PATH="$PATH:/usr/local/bin"
and run
npm install -g firebase-tools
this worked for me
Navigate to the firebase directory and call it out on the cmd.
run cmd as admin
cd C:\users\yourusername\AppData\Roaming\npm
firebase.cmd login or firebase login
firebase will prompt a google login after which the issue should be resolved.
There you go. above steps are all commands goes to your command prompt.
After running npm install -g firebase-tools, go to C:\usr\local. You will see Firebase files.
Copy this path C:\usr\local to the clipboard.
Open the Start Menu and search for Edit the System Environment Variables or simply env.
Select the environment variables option that appears.
Find the PATH variable under the system environment variables (lower section).
Select PATH and click Edit
Add C:\user\local to the beginning of the path.
Add %APPDATA%\npm if it doesn't exist.
Click OK to each of the windows until they're all closed.
After this, open a Windows command prompt and run firebase --version.
My solution is to use Firebase CLI binary for Windows:
Download CLI: https://firebase.google.com/docs/cli#install-cli-windows
Run CLI, go to the project directory (cd 'your app path'). By the way, you may see the version: run "firebase --version" for that
Run "firebase login" with Firebase CLI
Run "firebase init" with Firebase CLI
Make sure you are running command line as an administer.
Make sure you run the CMD in administrator mode. Also once you have run
npm install -g firebase-tools commands close the CMD prompt and reopen again. If this doesn't work uninstall node and reinstall it again. It requires your node version to be a minimum version to support firebase.
After installing
$ npm install -g firebase-tools
Note the directory where it installed
What I did was locate the directory where firebase was installed. In my case C:\usr\local then I copied the three firebase files. I also went into the node_modules folder and copied the firebase tools folder. Then I went to my app directory in file manager and pasted the firebase files, then created a new node_modules folder and pasted the firebase-tools folder.
Now go to your cmd and run
$ firebase init
It should work
1.After installing firebase globally via npm i -g firebase-tools
2.simply run all your firebase commands from the node command-line tool, it instantly worked for me.
3.To access the node command line, simply go to the start menu on windows and type "node.js command prompt"
Add this to the environment variable:-
C:\Users\<user>\AppData\Roaming\npm\firebase
it will allow firebase commands in ps/cmd
i dont think : C:\Users<user>\AppData\Roaming\npm\ now works.
I was struggling with this same issue for a few days and had an issue where my NPM was installed in two different places for whatever reason.
I had an npm folder in C:\Users\<user>\AppData\Roaming\npm\ as well as C:\Users\<user>\npm\
Turns out the Firebase installation command installed all the needed files into the latter folder, while my Environment PATH was pointing to the first folder.
I changed my PATH variable to C:\Users\<user>\npm\ and ran the firebase installation again. After that everything started working fine.
If you havent checked the other answers about what PATH is, you can access it by typing env in the Windows search bar and from there click the Environment Variables button. Then double click the Path line under System variables to edit it. Remember to press OK to save any changes.
This is probably a rare edgecase, but maybe it will help someone.
For peeps like me who were unable to get rid of this problem after trying everything suggested above.
I know it is late but I Fixed it by changing the location for installing my packages.
I ran the command "npm config get prefix" in cmd and I found out that my default location for node_modules installation had been changed.
so I set it back to default by "npm config set prefix "C:\Users\your_PC_Name\AppData\Roaming\npm".
After that I used "npm install -g firebase-tools" again
My firebase package was installed. I was relieved to see firebase.cmd file in npm folder.
Earlier I had tried every thing like uninstalling node.js and deleting npm and npm cache folders but all those methods didn't work for me.
Cannot get "npm install -g" to work on any packages (AppData/Roaming/npm always empty)
this discussion worked for me only.
all of the Simple and Quick solution is here... step1): just go to C:\Users\your-user-name\AppData\Roaming\npm step2): copy the path of this "npm"-folder step3): now go to start and type "env" and select first-option then step4): now paste that path in "paths"-option by clicking on "edit"-button step5): then click on "ok" and restart your pc
I had similar issue in MAC. Terminal was giving me command not found message on running "firebase --version". So, I tried to reinstall the firebase with the command: "sudo npm i g firebase-tools" but it again errored out stating that the installed firebase binary file is corrupted.
Solution:
STEP 1. Provide read, write and execute access with "sudo chmod a+rwx configstore" cmd to the path :
"/Users//.config/configstore/"
STEP 2. Run following command to update firebase:
sudo curl -sL firebase.tools | upgrade=true bash
Add C:\users\yourusername\AppData\Roaming\npm to your environment variable PATH.
For anyone still fighting this problem try to add the system environment path not to
a user's environment.
https://github.com/firebase/firebase-tools/issues/46#issuecomment-615534999
Run your cmd from C:\Windows\System32\cmd.exe or type this in your file path and hit Enter
Just reinstall firebas-tools {npm i firebase-tools -g} globally
Restart your computer its work for me good luck
Simple answer to this question is-
1.npm install firebase command in terminal window.
2.Add firebase scripts in your editor that you use.
3.set the Path in the environment system variable.
I think it will be able solve your problem...
My solution was that my project was on partition F: somedirectory/app, and when I moved it on partition C: Users/username/Documents/app It worked!
I tried everything mentioned and more, lost couple of hours.
So moving on partition where I installed: npm install -g firebase-tools
then: firebase login, then: firebase init
npx firebase <your command>
If you have similar problems like this
firebase : File C:\Users\<user-name>\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more em. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ firebase login
+ ~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
perhaps you can try to Ctrl + Click the C:\Users<user-name>\AppData\Roaming\npm\firebase.ps1
After that you'll see a new PowerShell Terminal and you can continue it.
Hope it's works
After trying to use the Windows Powershell (as an admin), the command prompt (as an admin) and the bash CMD; I repeatedly get the following error after trying an npm install command:
npm install npm#latest -g
is the attempted command and...
[...] / rollbackFailedOptional: verb npm-session xxxxxxxxxxx
where the 'x's represent different letter and number combinations at each attempt, is the message. I am aware that this should be the first step in the installation of a package but it remains on this message for a long time and will not change.
I am trying to use the JavaScript React library, more specifically the 'create-react-app'. The npm install -g create-react-app command is also causing the error.
npm version: 6.5.0
npx version: 10.2.0
node version: 10.15.0
A solution would be greatly appreciated.
https://docs.npmjs.com/try-the-latest-stable-version-of-npm In this link there is the documentation for updating npm version for windows with a link to a tool developed by Microsoft to update npm (https://github.com/felixrieseberg/npm-windows-upgrade)
I found the solution:
As my device username has both my first and last names, with a space in between, npm was reaching errors because of this. So the solution was to uninstall node from the default location and reinstall it in a folder on my C:\ drive, where there were no files in the directory that have spaces in the names. I then changed the cache location into this same C:\ drive folder, and the problem was solved.
npm config set cache C:\NODEJS\npm-cache
(these folders must be created before you can set the config directory to these.)
For me, I ended up having to:
Uninstall Node.js
Remove the folder "nodejs" completely from C:\Program Files (or
wherever you decided to install node)
Reinstall Node.js
After that, I did not encounter [...] / rollbackFailedOptional: verb npm-session xxxxxxxxxxx anymore.
I'm not quite sure what the issue was but all suggestions I found on stack did not solve this problem for me. I hope this helps someone.
Check if you are connected to any other VPN or proxy setting. If so try to disable it or disconnect from it and then execute the npm command. It worked for me. In my case, I was using the organization laptop and was connected to external vpn network, so i disabled the vpn and tried the command and it worked.
In our case the hard disc of the nexus server (repository server) was just full. Maybe someone helps this. Before looking into other more complicated options.
for my case i uninstalled the reinstelled it and used powershell insted of cmd and it worked like a charm
First run these commands.
npm config rm proxy
npm config rm https-proxy
then run this.
npm config set registry https://registry.npmjs.org/
check if the internet is connected
and try to run the npm command which was giving the error.
I used following command to create new angular project
ng new hello-world
It failed showing
npm WARN deprecated circular-json#0.5.9: CircularJSON is in maintenance only, flatted is its successor.
npm ERR! Unexpected end of JSON input while parsing near '...rocess":"~0.7.0"},"_h'
Then I installed flatted using...
npm i flatted
But the error still occurs.
How to use flatted instead of deprecated library circular-json?
Run following commands that will clean NPM cache
npm cache clean --force
after this run following command
npm install -g #angular/cli#latest
then you can create angular project.
If it doesn't work, even after clearing the cache, which happened in my case:
Make sure you try the ng new create-app command using Powershell in administrator mode.
This worked for me.
I had the same problem. None of the above mentioned answers worked for me.
So I removed the content of .npmrc, ran the generate command and it worked.
After that, you can restore the content of your .npmrc if needed.
I'm working with Yarn v0.16.1. If I understand correctly (according to the documentation), yarn global add <package> should be the equivalent of npm install -g <package>. However, when I run the example in the docs (with create-react-app), the command runs successfully but create-react-app is then not available from the command line. Here's the output:
$ yarn global add create-react-app
$ yarn global v0.16.1
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
success Installed create-react-app#0.6.0 with binaries:
- create-react-app
✨ Done in 3.22s.
$ create-react-app --help
-bash: create-react-app: command not found
Doing a global install with npm has the expected result, and everything works. What am I missing with yarn?
You should add export PATH="$PATH:$(yarn global bin)" to your ~/.bash_profile or whatever you use. It would solve the issue.
Depending on how you installed it, Yarn's global folder varies for some reason. You can follow this issue here.
Update Dec 2018
Just updating the path didn't work for me. I had to also set the yarn prefix.
Ubuntu 18.04.1 LTS (bionic)
yarn 1.12.3
npm v3.5.2
node v8.10.0
zsh 5.4.2
Steps
Confirm your global bin path
yarn global bin
I got: /home/username/.yarn/bin
set yarn prefix:
make sure your yarn prefix is the parent directory of your bin directory. You can confirm by running
yarn config get prefix
when I ran this, my prefix was empty, so I set it:
yarn config set prefix ~/.yarn
add the following to ~/.bash_profile or ~/.bashrc
export PATH="$PATH:`yarn global bin`"
for zsh users, be sure to add this line to ~/.zshrc
restart your shell or start a new one
bash -l or zsh
In my case yarn global bin wasn't working.
Try a brew reinstall yarn if that's how you installed yarn
👍🏻
Ran into this issue but on a Windows system. All I had to do was add the yarn global bin to the PATH variable.
setx path "%path%;c:\users\YOURUSERNAME\appdata\local\yarn\bin"
Remember to change YOURUSERNAME to your account username.
You can check where your global bin is by running
yarn global bin
And please don't forget to restart the CMD window that you're working on.
Happy coding!
! WARNING !
When executing the command that %path%; in front of your yarn directory is very important. If you don't type it you will definitely replace all your system environment variables.
Option 2
Safer option would be would be to just go to System Properties > Advanced > Environment Variables > select PATH the click Edit > then append and not replace with ;c:\users\YOURUSERNAME\appdata\local\yarn\bin
For macOS, you just need one step,
export PATH=~/.yarn/bin:$PATH
To reinstall run below.
brew install -g yarn
// Note:(updating homebrew) for Mac users.
brew reinstall yarn
// (if yarn is still not found)
Here's the process I used on Mac OSX El Capitan.
Try to install yarn (I used the Curl command) if you have it already. This will bring up if its already installed and will give you the current directory where it exists.
Like this:
curl -o- -L https://yarnpkg.com/install.sh | bash
It will display something like this:
Installing Yarn!
> /Users/{Your Username}/.yarn already exists, possibly from a past Yarn install.
> Remove it (rm -rf /Users/{Your Username}/.yarn) and run this script again.
Do not remove it. Move on to step 2.
Copy the directory listed above. Open your profile. I'm using zsh. So mine was ~/.zshrc. You can find yours and more info here.
Copy the following (replacing your directory and username details as necessary, the one you got from the installation error message).
alias yarn="/Users/{Your Username}/.yarn/bin/yarn"
Try to run yarn version to check if its working. If it is, you should see a version number displayed in your terminal.
That's it, and what worked for me.
AndrewD gave a great answer, but for those on Windows it's a bit different, especially step 3.
Please do not use the command setx as #Thapedict said.
It will remove all your previous paths you had and replace it with only the given directory.
If you want to use setx, I think there might be a flag to make it append the existing path variables, but I don't know which one. Using only setx will not append to it.
I would just do System Properties > Advanced > Environment Variables > Edit Path > New > c:\users\YOURUSERNAME\appdata\local\yarn\bin
to make sure you don't remove your previous variables.
export PATH="$PATH:$(yarn global bin)"
On Ubuntu, I fixed by installing the package like this:
sudo yarn global add <package> --prefix /usr/local
When switching from bash to zsh, I got the same error, it worked for me:
in your .zshrc
# NVM Stuff
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
# YVM Stuff
export YVM_DIR="$HOME/.yvm"
. "$(brew --prefix yvm)/yvm.sh"
As I understand it, my mistake arose due to the lack of access to version managers
I faced a similar issue on Windows after installing Yarn then Vue Cli.
Packages were installed but not accessible.
The problem was that the directory where yarn packages are installed is not in PATH.
The default installation directory for Yarn packages in my case was
C:\Users\USERNAME\AppData\Local\Yarn
So make sure to add this directory to path.
Putting this answer so that hopefully it can come in google and help others.
expo command not found after using
yarn global add expo-cli don't work in ubuntu 20.04
It's no longer necessary to modify your path for yarn
Newer versions of yarn include yarn create and yarn exec
In the case of create-react-app you can run yarn create react-app see this blog post https://classic.yarnpkg.com/blog/2017/05/12/introducing-yarn/
To run a non-creating package like serve, you can still run it without modifying your path! After installing it with yarn global add serve try this: yarn exec serve