“npm ls ELSPROBLEMS error: causes and fixes”
When npm error code ELSPROBLEMS appears at the end of the npm ls output, the packages in node_modules do not match the dependencies in package.json. Check the next line for missing: (a required package is not installed) or invalid: (the installed version does not match the range). Find out which package it is, then run npm install once, and the error goes away.
This error appears when you run npm ls to check the dependency list, or when npm ls exits with code 1 in a CI script and stops the job. I reproduced the error in my test environment, confirmed the full error message, and confirmed that running npm install clears it.
The test environment is Ubuntu 24.04. I mainly tested with Node.js 22.23.5 (npm 10.9.9). For comparison, I tested with npm 11.19.1, which comes with Node.js 24.22.3, for removing a package, changing a version range, and having an extra package. I tested with npm 9.9.4 for removing a package and having an extra package. The examples use ms, is-number, left-pad, and debug, and the registry is the default registry.npmjs.org. I did not test Windows, macOS, yarn, pnpm, workspaces, or globally installed packages (npm ls -g).
- 1. Message when a package is missing (missing)
- 2. Message when the version does not match (invalid)
- 3. When there are several problems, they are listed one per line
- 4. Running npm install clears the error
- 5. Extraneous packages do not cause an error
- 6. A missing dependency of a dependency appears only with –all
- 7. Differences between npm versions
Message when a package is missing (missing)
I created a project with npm init -y and installed two packages with npm install ms@^2.1.3 is-number@^7.0.0, so that npm ls ran without problems. Then I deleted only ms with rm -rf node_modules/ms and ran npm ls. With npm 10.9.9, the output was as follows (exit code 1). In the outputs in this article, I replaced the project path with /path/to/app and the log file path with ~/.npm/_logs. From the second output on, I omit the last log line (npm error A complete log of this run can be found in: …).
$ npm ls
app@1.0.0 /path/to/app
+-- is-number@7.0.0
`-- UNMET DEPENDENCY ms@^2.1.3
npm error code ELSPROBLEMS
npm error missing: ms@^2.1.3, required by app@1.0.0
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-24T11_44_09_817Z-debug-0.log
In the tree, a missing package is marked with UNMET DEPENDENCY. missing: ms@^2.1.3, required by app@1.0.0 means that app@1.0.0 needs ms in the range ^2.1.3, but it is not installed. The part after @ is the range written in package.json, not the version that is installed.
The same format appeared when I had only added a dependency to package.json and had not yet run npm install. This is the output of npm ls after I added "left-pad": "^1.3.0".
$ npm ls
app@1.0.0 /path/to/app
+-- is-number@7.0.0
+-- UNMET DEPENDENCY left-pad@^1.3.0
`-- ms@2.1.3
npm error code ELSPROBLEMS
npm error missing: left-pad@^1.3.0, required by app@1.0.0
Message when the version does not match (invalid)
With ms 2.1.3 installed, I changed the ms entry in package.json to ~2.0.0 and ran npm ls.
$ npm ls
app@1.0.0 /path/to/app
+-- is-number@7.0.0
+-- left-pad@1.3.0
`-- ms@2.1.3 invalid: "~2.0.0" from the root project
npm error code ELSPROBLEMS
npm error invalid: ms@2.1.3 /path/to/app/node_modules/ms
The tree line ms@2.1.3 invalid: "~2.0.0" from the root project means that 2.1.3 is installed, but the project itself (package.json) requires ~2.0.0. The npm error invalid: line shows the installed version and the path where it is installed. The tree is the only place that shows which range is required, so read both.
When there are several problems, they are listed one per line
I changed the ms entry back to ^2.1.3 (the installed version stayed 2.0.0), and also deleted node_modules/is-number. Then I ran npm ls. missing: and invalid: were listed one per line.
$ npm ls
app@1.0.0 /path/to/app
+-- UNMET DEPENDENCY is-number@^7.0.0
+-- left-pad@1.3.0
`-- ms@2.0.0 invalid: "^2.1.3" from the root project
npm error code ELSPROBLEMS
npm error missing: is-number@^7.0.0, required by app@1.0.0
npm error invalid: ms@2.0.0 /path/to/app/node_modules/ms
In the npm 10.9.9 source, npm ls collects missing:, invalid:, and extraneous: problems for each package it walks while printing the tree. It then joins them one per line into a single error with the code ELSPROBLEMS.
Running npm install clears the error
In both cases, running npm install once with no arguments fixed the problem. This is the result of running it in the state where missing: and invalid: were both listed.
$ npm install
added 1 package, changed 1 package, and audited 4 packages in 291ms
found 0 vulnerabilities
$ npm ls
app@1.0.0 /path/to/app
+-- is-number@7.0.0
+-- left-pad@1.3.0
`-- ms@2.1.3
added 1 package is the missing is-number being installed. changed 1 package is ms being replaced from 2.0.0 to 2.1.3. The npm ls after that had no error lines and exited with code 0.
When only ms was missing, when I added left-pad, and when I changed the ms entry to ~2.0.0, the npm ls after npm install also ended with exit code 0. When the range was changed, ms was replaced with 2.0.0, which matches the range in package.json.
npm ls --json reports the same problems in the problems field of the JSON. With ms missing, I ran it with standard error discarded (2>/dev/null). The beginning of the JSON on standard output was as follows (the rest is omitted). The npm error lines went to standard error, and the exit code stayed 1.
{
"version": "1.0.0",
"name": "app",
"problems": [
"missing: ms@^2.1.3, required by app@1.0.0"
],
Extraneous packages do not cause an error
I removed the left-pad line from package.json, leaving left-pad in node_modules, and ran npm ls.
$ npm ls
app@1.0.0 /path/to/app
+-- is-number@7.0.0
+-- left-pad@1.3.0 extraneous
`-- ms@2.1.3
The tree shows extraneous (an extra package that is not in any dependency list), but there is no ELSPROBLEMS line, and the exit code was 0. In the npm 10.9.9 source, the error is not raised when all the collected problems are extraneous:. npm 11.19.1 and npm 9.9.4 also exited with code 0 when there were only extraneous packages.
To remove extraneous packages, use npm prune. The official npm prune documentation describes it as the command that removes extraneous packages, meaning packages that are in node_modules but are not in any package's dependency list.
$ npm prune
removed 1 package, and audited 3 packages in 247ms
found 0 vulnerabilities
$ npm ls
app@1.0.0 /path/to/app
+-- is-number@7.0.0
`-- ms@2.1.3
A missing dependency of a dependency appears only with –all
Without options, npm ls shows only the packages that the project uses directly (official npm ls documentation). Whether a problem is found also depends on this display range.
In a project where only debug 2.6.9 was installed, ms 2.0.0, which debug uses, was installed along with it. I deleted this ms with rm -rf node_modules/ms and ran npm ls. There was no error, and the exit code was 0.
$ npm ls
app2@1.0.0 /path/to/app2
`-- debug@2.6.9
With --all, npm walked deeper and found the missing package (exit code 1).
$ npm ls --all
app2@1.0.0 /path/to/app2
`-- debug@2.6.9
`-- UNMET DEPENDENCY ms@2.0.0
npm error code ELSPROBLEMS
npm error missing: ms@2.0.0, required by debug@2.6.9
Since required by shows debug@2.6.9, you can read this as the ms that debug uses being missing. In this case too, running npm install installed ms 2.0.0, and npm ls --all ended with exit code 0. If you want to use npm ls in CI to confirm that all dependencies are present, problems at deeper levels will not be found unless you add --all.
Differences between npm versions
With npm 11.19.1, the missing: line when I deleted ms and the invalid: line when I changed the range to ~2.0.0 were the same as with npm 10.9.9.
With npm 9.9.4, each line starts with npm ERR!, and the error lines appear before the tree (log lines and blank lines are omitted).
$ npm ls
npm ERR! code ELSPROBLEMS
npm ERR! missing: ms@^2.1.3, required by app9@1.0.0
app9@1.0.0 /path/to/app9
`-- UNMET DEPENDENCY ms@^2.1.3
With npm 9.9.4 too, running npm install installed ms, and the npm ls after it ended with exit code 0.




