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 5 years have passed since last update.

npm経由からTypeScript環境をインストール時、Permission Errorとなる時の対処法

Last updated at Posted at 2019-01-18

下記のサイトを参考にnpm経由でtypescript環境をインストールしようとしたところ、次のエラーが表示されました。
https://code.visualstudio.com/Docs/languages/typescript

$ npm install -g typescript

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/*****/.npm/_logs/2019-01-18T13_16_12_727Z-debug.log

メッセージ中に表示されている、/usr/local/lib/node_modulesのパーミッションがrootになっているのが原因のようです。

$ pwd
/usr/local/lib
$ ls -l
drwxr-xr-x  3 root  wheel   96 12 26 14:40 dtrace
drwxr-xr-x  4 root  wheel  128  1 18 22:23 node_modules

下記のようにsudoでコマンドを実行すると、問題なくインストールできました。

$ sudo npm install -g typescript

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?