Friday, February 19, 2016

npm refusing to install as a dependency of itself

Cause : 
The name of the module you are trying to install cannot be same as the name you defined in package.json

Let's say, you are trying to install hapi module in hapi directory, rename the name to something other than hapi

{
  "name": "hapi-test",
  "version": "1.0.0",
  "description": "this is a test",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "keywords": [
    "test"
  ],
  "author": "wai",
  "license": "ISC",
  "dependencies": {
    "hapi": "^13.0.0"
  }
}

Here's more on package.json at https://docs.npmjs.com/files/package.json