IT story

Npm 루트 / 관리자로이 명령을 다시 사용하십시오.

hot-time 2020. 8. 31. 08:26
반응형

Npm 루트 / 관리자로이 명령을 다시 사용하십시오.


node.js를 사용하여 모듈을 설치하려고 필사적으로 시도했지만 항상 npm으로 패키지를 가져 오지 못했습니다.

관리자로 로그인하고 "관리자 권한으로 실행"과 함께 powershell / cmd를 사용했습니다. 나는 또한 레지스트리에 문제가있어서 npm set registry http://registry.npmjs.org/를 사용했습니다.

나는 모든 것을 시도했다 ... 그것은 나를 미치게 만든다.

오류는 다음과 같습니다.

npm 오류! 이 명령을 루트 / 관리자로 다시 실행 해보십시오.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "generator-knockout"
npm ERR! cwd D:\Sergiu\Knockout Test
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\block-stream\block-stream.js
npm ERR! fstream_path D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\block-stream\block-stream.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, lstat 'D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\block-stream\block-stream.js'
npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EPERM, lstat 'D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\fstream\LICENSE'
npm ERR!  { [Error: EPERM, lstat 'D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\fstream\LICENSE']
npm ERR!   errno: 50,
npm ERR!   code: 'EPERM',
npm ERR!   path: 'D:\\Sergiu\\Knockout Test\\node_modules\\generator-knockout\\node_modules\\yeoman-generator\\node_modules\\tar\\node_modules\\fstream\\LICENSE',
npm ERR!   fstream_type: 'File',
npm ERR!   fstream_path: 'D:\\Sergiu\\Knockout Test\\node_modules\\generator-knockout\\node_modules\\yeoman-generator\\node_modules\\tar\\node_modules\\fstream\\LICENSE',
npm ERR!   fstream_class: 'FileWriter',
npm ERR!   fstream_stack:
npm ERR!    [ 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\fstream\\lib\\writer.js:284:26',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

관리자 권한으로 명령을 다시 실행할 필요가 없으며 이렇게해도 문제가 해결되지 않습니다.

시험:

  1. npm cache clean 먼저.

  2. 그래도 문제가 해결되지 않으면을 살펴 %APPDATA%\npm-cache보거나 PowerShell을 사용하는 경우 $env:APPDATA\npm-cache.

캐시를 정리 한 후에도 남은 항목이 남아있을 수 있습니다. 해당 디렉토리의 모든 항목을 수동으로 제거하고 다시 시도하십시오. 이것은 항상 나를 위해 문제를 해결했습니다.

@Crazzymatt가 언급했듯이 npm @ 5 버전 이상 npm cache verify에서는 npm cache clean. 그렇지 않으면 이전과 같은 오류가 발생합니다.

npm 오류! npm @ 5부터는 npm 캐시가 손상 문제로자가 치유되고 캐시에서 추출 된 데이터의 유효성이 보장됩니다. 모든 것이 일관성이 있는지 확인하려면 대신 'npm cache verify'를 사용하세요.

(출처 : MSDN 블로그 게시물 )


관리자 cmd로 실행하여 해결합니다. 캐시를 청소 한 npm cache clean -f 다음 패키지를 다시 설치하십시오.


cmd.exe를 관리자로 실행해야합니다.

다음 단계를 따르십시오.

  • 시작, 모든 프로그램, 보조 프로그램을 차례로 클릭합니다.
  • 명령 프롬프트를 마우스 오른쪽 단추로 클릭 한 다음 관리자 권한으로 실행을 클릭합니다.

Windows (7) Dev에서이 문제를 해결 한 방법은 다음과 같습니다. 환경. 나는 다음을 가정합니다 ...

  • 당신은 실행되는 명령 프롬프트 , 힘내 배쉬 , Cmder int로서, 또는 당신의 마음에 드는 터미널 관리자 를 마우스 오른쪽 버튼으로 클릭하여
  • 권한 읽기 / 쓰기 권한이 부여되었습니다 (예 : chmod -777).

좋아, 해보자.

  1. 예를 들어 버전 확인에서 경고 ( "npm WARN"..)반환하는 패키지를 업데이트합니다 .

    npm 업데이트 -g npm

    npm 업데이트 -g graceful-fs

  2. 다음 으로 캐시강제정리 하려고합니다 . 이것은 '--f' 또는 '-f'로 표시됩니다 ..

    npm cache clean --f

  3. In Widows Explorer search for the following path

%APPDATA%\npm-cache

And Delete it's contents

  1. Start a fresh instance of your Terminal, remembering to 'Right-Click' and 'Run as Administrator', install the packages again.

Hope this helps someone!!


I was already running the Node Command Window as Administrator. As mentioned by many above, the following command with --f (force) solved my issue.

npm cache clean -f

After the Cache Clean, the install was flawless. See the screenshot for reference


I had to login into npm to resolve this issue.

npm login


If you're using TFS or any other source control for your project that sets your checked in files to readonly mode, then you gotta make sure package.json is checked out before running npm install. I've made this mistake plenty of times.


Try following steps

1. Run this command on Terminal or CMD - npm cache clean

2. Go to this folder on windows %APPDATA%\npm-cache And delete folder which you want to install module (Ex:- laravel-elixir) or if you are using PowerShell, $env:APPDATA\npm-cache

3. Then Run your command EX:- npm install laravel-elixir


Here is how I fixed the problem in Windows. I was trying to install the CLI for Angular.

  1. Turn off firewall and antivirus protections.

  2. Right click the nodejs folder (under Program Files), select Properties (scroll all the way down), click the Security tab, and click all items in the ALLOW column (for All System Packages and any user or group that allows you to add the “allow” checkmark).

  3. Click the Windows icon. Type cmd. Right click the top result and select Run as Administrator. A command window results.

  4. Type npm cache clean. If there is an error, close log files or anything open and rerun.

  5. Type npm install -g @angular/cli (Or whatever npm install command you are using)

  6. Check the installation by typing ng –version (Or whatever you need to verify your install)

Good luck! Note: If you are still having problems, check the Path in Environmental Variables. (To access: Control Panel → System and Security → System → Advanced system settings → Environment variables.) My path variable included the following: C:\Users\Michele\AppData\Roaming\npm


I had the same problem, what I did to solve it was ran the cmd.exe as administrator even though my account was already set as an administrator.


If you are doing this on mac type: sudo chown -R $USER /usr/local that will give you administrative access to your files


This is the flow often happens in this case. You run a command with no admin rights, you get message npm ERR! Please try running this command again as root/Administrator.. Then you open one more CLI(cmd, powershell, bash or whatever) and don't close the previous CLI. It appears you have 2 prompts opened in the same directory. And until you close CLI which runs with no admin rights you will be continuously getting npm ERR! Please try running this command again as root/Administrator. So close CLI which runs with no admins rights before running a new one.

NOTE: a lot of IDE has embedded CLI(Visual Studio, VS Code etc) so please close the instance of IDE as well


I had the same problem and I've fixed the error by cleaning the cache:

npm cache clean -f

What helped me on Windows 10 was just ticking off "Read Only" of project node_modules.


I messed with this problem 2 times and tried all suggestions here with mediocre success.

  • First time I tried (and succeeded luckily) by:

    1. delete the node_modules folder in your project

    2. npm clean cache -f

    3. check your %APPDATA%/npm-cache and delete everything if not empty

    4. start the terminal as administrator (in my opinion, it isnt a problem of rights, but it wont hurt if you do so)

    5. npm install and then npm update

    6. you will get errors, just install every module that throws an error manually and step by step try to eliminate everything whats wrong

However, this method is quite frustrating and not working everytime. So try this:

  • Second time I had no luck with the steps above, so I tried to completely reinstall npm and it failed. So I thought there must something be wrong with my node.js installation. My team is running 6.10. and I had the 6.11. and tried it with the 6.10. with no luck.

    1. So I completely wiped everything off my system. Deleted all node modules, checked every path where node or npm could be and cleaned my system.

    2. Then I installed newest 8.1.3

    3. Deleted my project and cloned it to a complete different directory.

    4. Now I installed and updated everything with npm install npm update

    5. Then I compiled with just 2 modules missing and installed them manually

Tadaaaaa, its working now. So all in all it was a problem with node.js. I recommend to everyone who runs into this problem: Try different node versions! And clean ABSOLUTE everything.


As my last resort with this error I created a fresh windows 10 virtual machine and installed the latest nodejs (v6). But there was a host of other "ERRs!" to work through.

I had to run npm cache clean --force which ironically will give you a message that reads "I sure hope you know what you are doing". That seems to have worked.

It doesn't solve the issue on my main Dev machine. I'm canning nodejs as I found over the last few years that you spend more time on fixing it rather than on actual development. I had fewer issues with node on linux ubuntu 14.04 if that's any help.


Deleting the global npm-cache and/or running my cmd line as admin did not work for me. Also, as of npm version 5.x.x, it supposedly recovers from cache corruption by itself.

This did work:

1. Deleted the node_modules folder in my current project.

2. Deleted the package-lock.json in my current project

3. Installed the new package. In my case: npm install bootstrap@next --save

4. Ran npm install for my current project.

Everything now works. In general, nuking node_modules and package-lock.json usually fix these "no apparent reason" bugs for me.

EDIT

I just had the same problem again. But I noticed that everything was installed correctly even though it threw the error after I had followed the steps outlined above. So I could just run ng serve (for Angular), and everything worked.

This sure is a weird error...


As a hack,

Check if the folder path it is complaining exists or not. If not, try creating them manually and rerun the installation, after clearing the cache

I had success with this, when running the installation from command prompt as an Administrator didn't work


$ npm cache clean
npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.

I tried running npm cache verify with admin rights and it worked after that.


npm cache verify

Try for newer versions of npm.

I'm using v 5.5.1 and it's working fine.


This worked for me, if your package.json is not too big you can do this:

  • Signout then signin.
  • Delete node_modules.
  • npm install again.

Like the other answers, clean npm cache and make sure the cache folder is empty, then run npm install several times. Each time the error message comes for different packages, and the final time (after X attempts) it succeeds.

  1. Run npm clean cache --force
  2. cd %APPDATA%\npm-cache (or cd $env:APPDATA\npm-cache for PowerShell)
  3. del * to delete everything in the folder
  4. Go back into the project folder and run npm install several times until it succeeds. Notice that the error messages come for different packages every time.

WHAT WORKED FOR ME

I ran Command Prompt as Administrator. This helped partially - as I no longer got the error, "Please try using this command again as root/administrator". I was trying to install Cordova. To do it successfully, I also had to do the following:

(1) "npm update node", plus...

(2) I also added the " -g " in the >>npm install cordova<<. In other words, type this: >>npm install -g cordova<<

~~~ FOR WINDOWS 8.1 ~~~

"RUN AS ADMINISTRATOR" COMMAND PROMPT

For windows 8.1, I don't have an ACCESSORIES group when I click START > ALL PROGRAMS. But I do have that older -- but trusty and reliable -- START BUTTON and START MENU - thanks to the free Classic Start Menu app. So, with that installed....

ALTERNATIVE #1:

1. Type "cmd" in the SEARCH BOX at the bottom of the START menu.  
2. When cmd.exe shows up in the top of the search results, right click it and select RUN AS ADMINISTRATOR.

ALTERNATIVE #2 If you already have a Command Prompt window open and running - and you want to open another one to Run As Administrator:

1. Locate the Command Prompt app icon in the Taskbar (usually along the bottom of you screen unless you have moved it a different dock/location).
2. Right click the app icon.
3. Now, right click "COMMAND PROMPT" and select RUN AS ADMINISTRATOR. 

Hope this helps someone.


I don't know which steps worked for me. But these are my steps to get rid of this error:

  1. Updated Node.js
  2. Ran npm cache clean command in Command prompt ( With some element of doubt for cache presence)
  3. Ran react-native init in command prompt as Administrator (on Windows OS), hoping works well with sudo react-native init on Mac OS

  1. Close the IDE
  2. Close the node terminals running ng serve or npm start
  3. Go to your project folder/node_modules and see you if can find the package that you are trying to install
  4. If you find the package you are searching then delete package folder
  5. In case, this is your 1st npm install then skip step 4 and delete everything inside the node_modules. If you don't find node_modules then create one folder in your project.
  6. Open the terminal in admin mode and do npm install.

That should fix the issue hopefully


FINALLY Got this working after 4 hours of installing, uninstalling, updating, blah blah.

The only thing that did it was to use an older version of node v8.9.1 x64

This was a PC windows 10.

Hope this helps someone.


If you're in react native project, and Expo is running, then close it.

Re-install the package, and everything should be fine.


Also remember to end all other commands e.g. npm run dev-server.


A solution that worked, is to close all PowerShell and cmd instances. Start PowerShell/cmd again as administrator and things seem to work.

This can happen if you're doing react-native and the node.js cmd is open in the background.


Fixing npm permissions in Ubuntu with a machine that has one local user, just in case:

Updgrade node:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

To see your local_user run the command:

whoami

The default directory that npm writes to is /usr/local and you can find it running this command:

npm config get prefix

Change the default directories user (root) to your user (local_user):

sudo chown -R local_user /usr/local/lib/node_modules/
sudo chown -R local_user /usr/local/bin/
sudo chown -R local_user /usr/local/share/

And that's it

참고URL : https://stackoverflow.com/questions/22325031/npm-please-try-using-this-command-again-as-root-administrator

반응형