これ解決するのに5時間くらいかかった。。発狂しそうや。。
ということで今回は、npm install実行時に出るエラー「operation not permitted」対策法について解説します!
エラー内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
17036 warn ajv-keywords@3.4.0 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself. 17037 verbose stack Error: EPERM: operation not permitted, unlink 'C:\Users\kohei.izumi\Desktop\tmp\reservation-client\node_modules\.staging\@angular\compiler-89a4d5c8\bundles\compiler.umd.js.map' 17038 verbose cwd C:\Users\kohei.izumi\Desktop\tmp\reservation-client 17039 verbose Windows_NT 10.0.15063 17040 verbose argv "C:\\Program Files (x86)\\Nodist\\v-x64\\11.11.0\\node.exe" "C:\\Program Files (x86)\\Nodist\\npmv\\6.7.0\\bin\\npm-cli.js" "install" 17041 verbose node v11.11.0 17042 verbose npm v6.7.0 17043 error path C:\Users\kohei.izumi\Desktop\tmp\reservation-client\node_modules\.staging\@angular\compiler-89a4d5c8\bundles\compiler.umd.js.map 17044 error code EPERM 17045 error errno -4048 17046 error syscall unlink 17047 error Error: EPERM: operation not permitted, unlink 'C:\Users\kohei.izumi\Desktop\tmp\reservation-client\node_modules\.staging\@angular\compiler-89a4d5c8\bundles\compiler.umd.js.map' 17047 error { [Error: EPERM: operation not permitted, unlink 'C:\Users\kohei.izumi\Desktop\tmp\reservation-client\node_modules\.staging\@angular\compiler-89a4d5c8\bundles\compiler.umd.js.map'] 17047 error cause: 17047 error { Error: EPERM: operation not permitted, unlink 'C:\Users\kohei.izumi\Desktop\tmp\reservation-client\node_modules\.staging\@angular\compiler-89a4d5c8\bundles\compiler.umd.js.map' 17047 error errno: -4048, 17047 error code: 'EPERM', 17047 error syscall: 'unlink', 17047 error path: 17047 error 'C:\\Users\\kohei.izumi\\Desktop\\tmp\\reservation-client\\node_modules\\.staging\\@angular\\compiler-89a4d5c8\\bundles\\compiler.umd.js.map' }, 17047 error stack: 17047 error "Error: EPERM: operation not permitted, unlink 'C:\\Users\\kohei.izumi\\Desktop\\tmp\\reservation-client\\node_modules\\.staging\\@angular\\compiler-89a4d5c8\\bundles\\compiler.umd.js.map'", 17047 error errno: -4048, 17047 error code: 'EPERM', 17047 error syscall: 'unlink', 17047 error path: 17047 error 'C:\\Users\\kohei.izumi\\Desktop\\tmp\\reservation-client\\node_modules\\.staging\\@angular\\compiler-89a4d5c8\\bundles\\compiler.umd.js.map', 17047 error parent: 'reservation-client' } 17048 error The operation was rejected by your operating system. 17048 error It's possible that the file was already in use (by a text editor or antivirus), 17048 error or that you lack permissions to access it. 17048 error 17048 error If you believe this might be a permissions issue, please double-check the 17048 error permissions of the file and its containing directories, or try running 17048 error the command again as root/Administrator (though this is not recommended). 17049 verbose exit [ -4048, true ] |
で、解決方法は??
結論から言うと、「npmのバージョンをダウングレードする」ことで解決します。
nodeは複数のバージョンをインストールできるので、ダウングレードするというよりは、「古いバージョンのnodeをインストールする」が正しいですね。
どのバージョンのnpmをインストールするのかと言うと、僕は「4.0.5」のnpmをインストールしました。
「5.0.3」でもおそらく問題ないですが、どこまで大丈夫なのかは調査していないので分かりません。
参考サイト
まとめ
今回のエラーはnpmのバグなのでしょうかね?
良く分かりませんが、nodeはこういった意味不明なエラーが多すぎて困ります。
「なんとかしろやこら!!」って感じですが、まあ解決したので良しとします。
ではまた!