masalibの日記

システム開発、運用と猫の写真ブログです

npm installで”EPERM: operation not permitted ,mkdir”とエラーが出る場合

npm installする際に下記のようなエラーに遭遇しましたので、忘れないようメモ代わりに書いています。
環境は windows10 64bit です。

error path C:\git\blog\node_modules\@types
error code EPERM
error errno -4048
error syscall mkdir
error Error: EPERM: operation not permitted, mkdir 'C:\git\blog\node_modules\@types'
error  { [Error: EPERM: operation not permitted, mkdir 'C:\git\blog\node_modules\@types']
error   cause:
error    { Error: EPERM: operation not permitted, mkdir 'C:\git\blog\node_modules\@types'
error      errno: -4048,
error      code: 'EPERM',
error      syscall: 'mkdir',
error      path: 'C:\\git\\blog\\node_modules\\@types' },
error   stack:
error    'Error: EPERM: operation not permitted, mkdir \'C:\\git\\blog\\node_modules\\@types\'',
error   errno: -4048,
error   code: 'EPERM',
error   syscall: 'mkdir',
error   path: 'C:\\git\\blog\\node_modules\\@types',
error   parent: 'gatsby-starter-lumen' }
error The operation was rejected by your operating system.
error It's possible that the file was already in use (by a text editor or antivirus),
error or that you lack permissions to access it.

https://www.amelt.net/imc/programming/nodejs/5028/

どこかで中途半端に npm install が失敗したせいで、
キャッシュが残ってしまっているのが原因と記載されていた
なので

npm cache clean

を実行したがエラーが解消されなかった\(^o^)/

ちょうどnode.jsのバージョンが古かったのでバージョンアップしたら
問題なく動いた。
意味わかんない

バージョンアップは下記からインストラーをダウンロードして実行するのみです

nodejs.org