Solving NPM Refusing to Install Package as a Dependency of Itself Error

Solving NPM Refusing to Install Package as a Dependency of Itself Error

I use npm init command to generate new fresh Node.js project. I did that and tried to install the node module using following command.

npm i --S mqtt

But it responded with big error stack trace like this.

NPM Refusing to Install Package as a Dependency of Itself

I received this error for the first time since I started with Node.js development.

I wasted my next 10 minutes to figure out what went wrong and when I figured it out, I felt like this!

So this is how I solved it.

This error means that the Node module which you are trying to install as the dependency is actually your project name!

To fix that, open your package.json file and change the name of the project.

NPM Refusing to Install Package as a Dependency of Itself

Now, try to install the module again.

NPM Refusing to Install Package as a Dependency of Itself

It worked!

This was just a tip to save your time to fix this stupid error.

Do you think NodeJS should give the error in a more descriptive way? Let me know in comments.

Shahid (UnixRoot) Shaikh

Hey there, This is Shahid, an Engineer and Blogger from Bombay. I am also an Author and i wrote a programming book on Sails.js, MVC framework for Node.js.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *