Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm ERR Refusing to install package with name <packageName> under a package also called <packageName>

I am trying to use the jsonfile package in my project, but I get the following errors:

  1. Refusing to install package with name <packagename> under a package also called <packagename>. (Note that none of the directory or filename is same as package name)

  2. Cannot find module <packagename>.

enter image description here

enter image description here

like image 202
Infinity Avatar asked Sep 05 '18 07:09

Infinity


1 Answers

The problem is caused when the name of project in package.json is the same as the module you're trying to install.

To solve this problem, please change the project name in package.json to something else. For example, "jsonfile-test":

{
  "name": "jsonfile-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
  }
}
like image 134
Thao Nguyen Tien Avatar answered Nov 10 '22 07:11

Thao Nguyen Tien