{"_id":"is-network-error","_rev":"4130117","name":"is-network-error","description":"Check if a value is a Fetch network error","dist-tags":{"latest":"1.3.1"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-03-01T18:31:33.000Z","created":"2023-09-26T14:15:09.619Z","1.3.1":"2026-02-26T13:51:46.844Z","1.3.0":"2025-09-18T16:43:20.189Z","1.2.0":"2025-09-16T16:41:07.774Z","1.1.0":"2024-03-19T12:38:31.098Z","1.0.1":"2024-01-04T01:38:41.893Z","1.0.0":"2023-09-26T14:15:09.619Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"versions":{"1.3.1":{"name":"is-network-error","version":"1.3.1","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"gitHead":"ca6cca4f05caf415515d7646e42b1edc82927082","types":"./index.d.ts","_id":"is-network-error@1.3.1","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"shasum":"a2a86b80ffd6b05b774755c73c8aaab16597e58d","size":2469,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-network-error/download/is-network-error-1.3.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/is-network-error_1.3.1_1772113906719_0.12846963177350545"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-26T13:51:46.844Z","publish_time":1772113906844,"_source_registry_name":"default","_cnpm_publish_time":1772113906844},"1.3.0":{"name":"is-network-error","version":"1.3.0","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"_id":"is-network-error@1.3.0","gitHead":"b119a91971649acc9893efc5aba70be044213b60","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_nodeVersion":"20.19.5","_npmVersion":"10.9.2","dist":{"shasum":"2ce62cbca444abd506f8a900f39d20b898d37512","size":2421,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-network-error/download/is-network-error-1.3.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/is-network-error_1.3.0_1758213800006_0.10742027568507417"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-18T16:43:20.189Z","publish_time":1758213800189,"_source_registry_name":"default","_cnpm_publish_time":1758213800189},"1.2.0":{"name":"is-network-error","version":"1.2.0","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"_id":"is-network-error@1.2.0","gitHead":"fdec607d793f11a003965078033b19430d4abde0","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_nodeVersion":"20.19.5","_npmVersion":"10.9.2","dist":{"shasum":"ca807bbd4f33967d9954fc7f02bf4176254d71b3","size":2394,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-network-error/download/is-network-error-1.2.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/is-network-error_1.2.0_1758040867578_0.35605332681132174"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-16T16:41:07.774Z","publish_time":1758040867774,"_source_registry_name":"default","_cnpm_publish_time":1758040867774},"1.1.0":{"name":"is-network-error","version":"1.1.0","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"9710d1f0e1f75e6775bbedc909fcb96851031787","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_id":"is-network-error@1.1.0","_nodeVersion":"20.11.1","_npmVersion":"9.2.0","dist":{"shasum":"d26a760e3770226d11c169052f266a4803d9c997","size":2217,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-network-error/download/is-network-error-1.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/is-network-error_1.1.0_1710851910941_0.9807955355246603"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-19T12:38:31.098Z","publish_time":1710851911098,"_source_registry_name":"default","_cnpm_publish_time":1710851911098},"1.0.1":{"name":"is-network-error","version":"1.0.1","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"bb1d9eaff47c5391bdfa834364ffcafd2c353c1d","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_id":"is-network-error@1.0.1","_nodeVersion":"21.2.0","_npmVersion":"9.2.0","dist":{"shasum":"a68061a20387e9144e145571bea693056a370b92","size":2205,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-network-error/download/is-network-error-1.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/is-network-error_1.0.1_1704332321723_0.7927684548450891"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-01-04T01:38:41.893Z","publish_time":1704332321893,"_source_registry_name":"default","_cnpm_publish_time":1704332321893},"1.0.0":{"name":"is-network-error","version":"1.0.0","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"88b46c29fcb69700ab8919be1fd322a234ccbf40","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_id":"is-network-error@1.0.0","_nodeVersion":"16.20.0","_npmVersion":"9.2.0","dist":{"shasum":"757d7af42263f18f616626e63af12abb19002bbc","size":2190,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-network-error/download/is-network-error-1.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/is-network-error_1.0.0_1695737709369_0.7316419387319419"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-09-26T14:15:09.619Z","publish_time":1695737709619,"_source_registry_name":"default","_cnpm_publish_time":1695737709619}},"readme":"# is-network-error\n\n> Check if a value is a [Fetch network error](https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions)\n\nThis can be useful when you want to do something specific when a network error happens without catching other Fetch-related errors.\n\nUnfortunately, Fetch network errors are [not standardized](https://github.com/whatwg/fetch/issues/526) and differ among implementations. This package handles the differences across Node.js, Bun, Deno, and browsers.\n\nFor instance, [`p-retry`](https://github.com/sindresorhus/p-retry) uses this package to retry on network errors.\n\n## Install\n\n```sh\nnpm install is-network-error\n```\n\n## Usage\n\n```js\nimport isNetworkError from 'is-network-error';\n\nasync function getUnicorns() {\n\ttry {\n\t\tconst response = await fetch('unicorns.json');\n\t\treturn await response.json();\n\t} catch (error) {\n\t\tif (isNetworkError(error)) {\n\t\t\treturn localStorage.getItem('…');\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nconsole.log(await getUnicorns());\n```\n\n## API\n\n### `isNetworkError(value: unknown): value is TypeError`\n\nReturns `true` if the given value is a Fetch network error, otherwise `false`.\n\nThis function acts as a type guard, narrowing the type to `TypeError` when it returns `true`.\n","_attachments":{},"homepage":"https://github.com/sindresorhus/is-network-error#readme","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"license":"MIT"}