Reputation: 441
I am trying to use the jsonfile package in my project, but I get the following errors:
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)
Cannot find module <packagename>.
Upvotes: 20
Views: 16940
Reputation: 869
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": {
}
}
Upvotes: 54
Reputation: 313
I think it should be:
npm install --save json-file
not
npm install --save jsonfile
ref: https://www.npmjs.com/package/json-file
If that does not work please try enabling permissions install - e.g. (on mac- but will be equivalent on windows, check: https://helpdeskgeek.com/free-tools-review/5-windows-alternatives-linux-sudo-command/) run:
sudo npm install --save json-file
Upvotes: -1