1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WSLでnpm uninstall時にpermission deniedエラーが出る

Posted at

WSL上に環境構築したnpmでパッケージ管理しているプロジェクトで、ライブラリをuninstallするときに、以下のエラーが出た。

$ npm install {ライブラリ名}

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/~/project/frontend/node_modules/ansi-colors
npm ERR! dest /home/~/project/frontend/node_modules/.ansi-colors-fx0IfCCD
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/~/project/frontend/node_modules/ansi-colors' -> '/home/~/project/frontend/node_modules/.ansi-colors-fx0IfCCD'
npm ERR!  [Error: EACCES: permission denied, rename '/home/~/project/frontend/node_modules/ansi-colors' -> '/home/~/project/frontend/node_modules/.ansi-colors-fx0IfCCD'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/home/~/project/frontend/node_modules/ansi-colors',
npm ERR!   dest: '/home/~/project/frontend/node_modules/.ansi-colors-fx0IfCCD'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/~/.npm/_logs/2023-04-15T23_20_51_237Z-debug-0.log

ワークアラウンドは以下の通り
①エディタのウィンドウを閉じる(その他WSLのターミナルを開いているウィンドウは全部閉じる)
②WSLのWindowsアプリを管理者権限で実行
③プロジェクトのフォルダに移動して、npm uninstallを実行

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?