3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\username\AppData\Roaming\npm'のエラーを解決する。

Posted at

解決方法

npmを最新化する。

バージョン

node: v20.11.1
npm: 10.2.4 -> 10.5.0
windows: Windows 11 Home 23H2

具体的手順

Windowsの環境で実施します。

(1) 下記を実施し、node, npmが正しくインストールされているか、PATHが通っているかを確認。

node -v
npm -v

(2) PATHが通っていたら、npmを最新化。

npm install -g npm

(3) 一応cacheも消す。

npm cache clean -f

(4) 再度npm installすると同エラーは出なくなる。


引用元:

問題

npm installで下記エラーが起きた。

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\username\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\username\AppData\Roaming\npm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

詳細なログを見てみると、以下のようになっていた。

...
35 http fetch GET 200 https://registry.npmjs.org/cmake-js 111ms (cache revalidated)
36 timing arborist:ctor Completed in 0ms
37 timing command:exec Completed in 150ms
38 verbose stack Error: ENOENT: no such file or directory, lstat 'C:\Users\username\AppData\Roaming\npm'
39 verbose cwd C:\Users\username\Documents\Programing\JavaScript\talk\whisper.cpp
40 verbose Windows_NT 10.0.22631
41 verbose node v20.11.1
42 verbose npm  v10.2.4
43 error code ENOENT
44 error syscall lstat
45 error path C:\Users\username\AppData\Roaming\npm
46 error errno -4058
47 error enoent ENOENT: no such file or directory, lstat 'C:\Users\username\AppData\Roaming\npm'
48 error enoent This is related to npm not being able to find a file.
48 error enoent
49 verbose exit -4058
50 timing npm Completed in 450ms
51 verbose code -4058
52 error A complete log of this run can be found in: C:\Users\username\AppData\Local\npm-cache\_logs\2024-03-23T06_10_20_138Z-debug-0.log

どうやら、AppData/Roaming配下のnpmが見つからない。

47 error enoent ENOENT: no such file or directory, lstat 'C:\Users\username\AppData\Roaming\npm'

これを、先述の方法で解決した。

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?