npm installで出るE404 Not Foundの原因と直し方

​​npm​Node.js,トラブルシュート

npm install で npm error code E404 と 404 Not Found - GET https://registry.npmjs.org/パッケージ名 - Not found が出たら、打ったパッケージ名がレジストリ(npm のパッケージの置き場所)にありません。公開パッケージを入れようとしているなら、まず名前の打ち間違いを疑います。npm view パッケージ名 name で名前があるかを確かめ、正しい名前で入れ直せば、エラーは消えます。

READMEや記事を見ながらライブラリを追加するときに、パッケージ名を手で打って1文字多く入れたり、文字の順番を入れ替えたりすると出るエラーです。私は検証環境で dayjs などの名前をわざと打ち間違え、どの行に何が出るかと、名前を直せばインストールが通ることを試しました。

補足

検証環境は Ubuntu 24.04 です。主に Node.js 22.23.4(npm 10.9.9)で試し、比べるために npm 9.9.4 と、Node.js 24.22.1 に付いてくる npm 11.19.1 でも同じ操作をしました。レジストリは標準の registry.npmjs.org です。Windows と macOS、yarn や pnpm、社内向けなど別のレジストリ、ログインが必要な非公開パッケージは試していません。

dayjs を dayjss と打ったときの全文

npm init -y で作った空のプロジェクトで、日付を扱うライブラリ dayjs を入れようとして、s を1つ多く打って dayjss にしました。npm 10.9.9 では次のように出て止まりました(終了コードは1)。この記事の出力では、ログファイルのパスを ~/.npm/_logs に置き換えています。

text
$ npm install dayjss
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/dayjss - Not found
npm error 404
npm error 404  'dayjss@*' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-12T11_36_51_335Z-debug-0.log

404 Not Found - GET … の行は、npm がレジストリに dayjss の情報を取りに行き(GET)、「見つからない」(404 Not Found)と返されたことを示しています。is not in this registry. の行は「dayjss のどのバージョンも(@*)、このレジストリにはない」という意味です。バージョンを指定しなかったので @* が付いています。

最後の2行は「tarball(.tgz ファイル)、フォルダー、URL、git の URL からもインストールできます」という案内です。npm 10.9.9 のソース(lib/utils/error-message.js)では、E404 でパッケージ名が分かっているときに、この2行を付けています。打ち間違いのときは関係ないので、読み飛ばしてかまいません。

エラーで止まったあとも、package.json の dependencies は空のままで、node_modules もできていませんでした。

npm のバージョンによる表示の違い

npm 11.19.1 では、is not in this registry. の行の文が変わり、「見つからないか、アクセスする権限がない」という書き方になりました。

text
npm error 404  The requested resource 'dayjss@*' could not be found or you do not have permission to access it.

権限がない場合も含めた書き方ですが、公開パッケージなら、原因は同じく名前の打ち間違いです。

npm 9.9.4 では、行頭が npm ERR! になり、最後の行の前に空行が入りました。

text
$ npx -y npm@9.9.4 install dayjss
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/dayjss - Not found
npm ERR! 404 
npm ERR! 404  'dayjss@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: ~/.npm/_logs/2026-11-12T11_36_57_808Z-debug-0.log

スコープ付きの名前や、大文字を打ったとき

@tanstack/react-query のように @ で始まるスコープ付きの名前でも、打ち間違えると同じ E404 になります。query を qeury と打ったときは、URL の / が %2f に置き換わって表示されました。

text
$ npm install @tanstack/react-qeury
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@tanstack%2freact-qeury - Not found
npm error 404
npm error 404  '@tanstack/react-qeury@*' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-12T11_36_51_705Z-debug-0.log

ライブラリの表記(Day.js など)につられて、名前に大文字を混ぜたときは、名前が使えない理由を示す行が2行増えました。

text
$ npm install Dayjs
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/Dayjs - Not found
npm error 404
npm error 404  'Dayjs@*' is not in this registry.
npm error 404 This package name is not valid, because 
npm error 404  1. name can no longer contain capital letters
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-12T11_36_51_977Z-debug-0.log

name can no longer contain capital letters は「名前にはもう大文字を使えない」という意味です。package.json の公式ドキュメントにも、新しいパッケージの名前には大文字を使えないと書かれています。この行が出たら、名前をすべて小文字にして打ち直します。

npm view で、名前があるかを確かめる

npm view の公式ドキュメントにあるとおり、npm view はパッケージの情報を表示するコマンドです。名前がなければ npm install と同じ E404 になり、あれば情報が出るので、インストールの前に名前を確かめるのに使えます。

text
$ npm view dayjs name version
name = 'dayjs'
version = '1.11.23'

正しい名前が分からないときは、覚えている部分で検索できます。npm search の公式ドキュメントにあるとおり、npm search はレジストリのパッケージを検索するコマンドです。検証で npm search dayjs --searchlimit=3 を実行すると、dayjs と、名前に dayjs を含むプラグイン2つが、説明とバージョンを添えて並びました。ライブラリの公式ドキュメントにインストールのコマンドが書かれていれば、それをコピーして貼り付けると、打ち間違いを避けられます。

正しい名前の dayjs で入れ直す

正しい名前 dayjs で入れ直すと、エラーは出ずに終わりました(終了コードは0)。

text
$ npm install dayjs

added 1 package, and audited 2 packages in 339ms

found 0 vulnerabilities

package.json の dependencies には "dayjs": "^1.11.23" が書かれ、npm ls でも dayjs 1.11.23 が入っていることを確かめました。

package.json に打ち間違えた名前が書いてあるとき

package.json を手で編集して、dependencies に打ち間違えた名前を書いた場合も、引数なしの npm install で同じエラーになりました。is not in this registry. の行の @ の後ろには、package.json に書いたバージョンの範囲が入ります。

text
$ npm pkg get dependencies
{
  "dayjss": "^1.11.0"
}
$ npm install
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/dayjss - Not found
npm error 404
npm error 404  'dayjss@^1.11.0' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-12T11_36_53_865Z-debug-0.log

このときは、package.json の名前を直します。検証では、npm pkg delete で間違った名前を消し、npm pkg set で正しい名前を書いてから npm install しました。

text
$ npm pkg delete dependencies.dayjss
$ npm pkg set dependencies.dayjs=^1.11.0
$ npm install

added 1 package, and audited 2 packages in 416ms

found 0 vulnerabilities

エラーは消え、範囲 ^1.11.0 に合う中でいちばん新しい 1.11.23 が入りました。

E404 が出ない打ち間違いもある

打ち間違えても、その名前のパッケージがレジストリにあれば E404 にはなりません。よく使われるライブラリの名前を少し変えた名前は、すでに別のパッケージとして登録されていることがあります。検証では、次の名前がどれもレジストリにありました(npm view で調べました。インストールしたのは、あとで述べる axois だけです)。

打った名前 本来の名前 npm view で出た説明
expres express Add express compatible methods to your response object
axois axios security holding package
lodahs lodash security holding package

expres は、express とは別のパッケージです。axois と lodahs は、説明が security holding package で、バージョンは 0.0.1-security でした。このうち axois を、使い捨ての作業ディレクトリで npm install axois してみました。エラーは出ずに終わり(終了コードは0)、package.json の dependencies には "axois": "^0.0.1-security" が書かれました。入ったのは README.md と package.json だけのパッケージで、axios ではありません。

注意

npm install のあとは、package.json の dependencies に書かれた名前が、入れたかったライブラリの名前と一字一句同じかを確かめてください。

なお、名前は合っていてバージョンの指定が公開済みのものと合わないときは、E404 ではなく ETARGET になります。その場合の調べ方は、別の記事「npm installで出るETARGETエラーの原因と直し方」にまとめています。

​Posted by 86