json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Command to install json-server is not working

Open AliSinaSaemi opened this issue 6 years ago • 6 comments

Hello there, I am trying to make my first fake server but I couldn't because " npm install --save json-server " is not working at all

npm verison: 6.12.0 node version: 12.12.0

This is the whole error: npm ERR! code ENOSELF npm ERR! Refusing to install package with name "json-server" under a package npm ERR! also called "json-server". Did you name your project the same npm ERR! as the dependency you're installing? npm ERR! npm ERR! For more information, see: npm ERR! https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Alisina\AppData\Roaming\npm-cache_logs\2019-11-08T22_18_10_208Z-debug.log

and my log:

0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'i', 1 verbose cli 'json-server' 1 verbose cli ] 2 info using [email protected] 3 info using [email protected] 4 verbose npm-session fabc65bf999d99ec 5 silly install loadCurrentTree 6 silly install readLocalPackageData 7 http fetch GET 304 https://registry.npmjs.org/json-server 833ms (from cache) 8 silly pacote tag manifest for json-server@latest fetched in 851ms 9 timing stage:loadCurrentTree Completed in 875ms 10 silly install loadIdealTree 11 silly install cloneCurrentTreeToIdealTree 12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms 13 silly install loadShrinkwrap 14 timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms 15 silly install loadAllDepsIntoIdealTree 16 timing stage:rollbackFailedOptional Completed in 0ms 17 timing stage:runTopLevelLifecycles Completed in 878ms 18 silly saveTree [email protected] 19 verbose stack Error: Refusing to install package with name "json-server" under a package 19 verbose stack also called "json-server". Did you name your project the same 19 verbose stack as the dependency you're installing? 19 verbose stack 19 verbose stack For more information, see: 19 verbose stack https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm 19 verbose stack at checkSelf (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\lib\install\validate-args.js:75:14) 19 verbose stack at Array. (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8) 19 verbose stack at LOOP (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:15:14) 19 verbose stack at C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:18:7 19 verbose stack at hasMinimumFields (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\lib\install\validate-args.js:30:12) 19 verbose stack at Array. (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8) 19 verbose stack at LOOP (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:15:14) 19 verbose stack at chain (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:20:5) 19 verbose stack at C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\lib\install\validate-args.js:16:5 19 verbose stack at C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:35 19 verbose stack at Array.forEach () 19 verbose stack at C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:11 19 verbose stack at Array.forEach () 19 verbose stack at asyncMap (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:51:8) 19 verbose stack at module.exports (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\lib\install\validate-args.js:15:3) 19 verbose stack at Array. (C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8) 20 verbose cwd e:\Reactjs Samples\JSON-SERVER 21 verbose Windows_NT 10.0.16299 22 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\Alisina\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "i" "json-server" 23 verbose node v12.12.0 24 verbose npm v6.12.0 25 error code ENOSELF 26 error Refusing to install package with name "json-server" under a package 26 error also called "json-server". Did you name your project the same 26 error as the dependency you're installing? 26 error 26 error For more information, see: 26 error https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm 27 verbose exit [ 1, true ]

AliSinaSaemi avatar Nov 08 '19 22:11 AliSinaSaemi

Hello,

Don't know if you found the solution but the error message seems to say it all

npm ERR! Refusing to install package with name "json-server" under a package npm ERR! also called "json-server". Did you name your project the

26 error Refusing to install package with name "json-server" under a package 26 error also called "json-server". Did you name your project the same 26 error as the dependency you're installing?

amglt avatar Jan 28 '20 15:01 amglt

check if the package.json "name" property is not "json-server", this may conflict and generate this error

luanmbrito avatar Apr 30 '20 13:04 luanmbrito

hello, this is my first trial of creating fake server, using (npm install --save json-server) but facing these errors image what is problem? help me out.

Murkhassan86 avatar Jul 18 '20 07:07 Murkhassan86

Use node command prompt and type npm install -g json-server Or yarn global add json-server

It should work fine.

Epitomekennie avatar Jul 26 '20 20:07 Epitomekennie

Thanks a lot 😊

zitchauhan avatar Aug 29 '20 09:08 zitchauhan

yarn global add json-server

Thanks for the "yarn" command!! it really helped me!!

ShreyasHarinath avatar Mar 12 '22 20:03 ShreyasHarinath