What npm Is Rejecting
npm returned ENOSELF because the package name matches the project you are trying to install, creating a self-dependency.
Fix the command
Run npm help <command> and confirm correct flags and argument order.
Print npm version:npm -v and update if you are using an old version.
If this started after config changes, temporarily move .npmrc aside and retry.
Manual debugging checklist
Print the exact command and tool version you are using, then compare it to the version-specific help output for that command.
Check the current working directory and any config files the tool is reading, because many usage errors come from running the right command in the wrong place.
Strip the command back to the minimal working form, then add flags back one at a time until the invalid combination becomes obvious.
Typical Output
npm ERR! code ENOSELF
npm ERR! Refusing to install package as a dependency of itself Why the Command Was Rejected
Usually this comes down to the command was invoked with invalid flags or arguments, or the environment or .npmrc contains an unsupported option for your npm version.
Re-run the Minimal Correct Command
Re-run the same command with corrected flags and confirm it completes.
Restore config only after confirming which setting caused the issue.
How npm executes the command
npm rejected the command before it got to the real work. That usually means the current directory, flags, arguments, or local configuration did not make sense for the operation you asked it to perform. These errors are often resolved by simplifying the command, checking the version-specific help output for the flags in use, and verifying the working directory or config file that the tool actually read.
Avoid Command and Config Drift
To prevent this, pin npm versions in CI, and keep .npmrc minimal and documented.
Docs and source code
github.com/npm/cli/blob/7e679fdc862a7176c290b51db91b189f5c6a0c95/lib/install/validate-args.js
Open-source npm CLI code reference from v6.0.0 (legacy error code path). - GitHub
'as the dependency you\'re installing?\n\n' +
'For more information, see:\n' +
' <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>')
er.code = 'ENOSELF'
next(er)
}
}