Home > Back-end >  Error while running the command npm install
Error while running the command npm install

Time:04-29

I'm trying to run a react code and used the command npm install and error(s) pop up:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\AJ\Desktop\Test/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\AJ\Desktop\Test\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!      C:\Users\AJ\AppData\Local\npm-cache\_logs\2022-04-29T05_40_15_503Z-debug-0.log

Help me resolve these errors, Thanks in advance!

CodePudding user response:

The issue seems to be that npm can't find the package.json file.

Normally, this is a very simple problem that can be fixed easily.


1. Not in the directory of package.json

If you already have the package.json file, then you need to make sure that you are in the directory in which the file is in.

To see if the file is in your directory, run the dir command.

$ dir

If you aren't in the directory in which package.json is in, then navigate to that directory.


2. Creation of package.json

Another issue that can occur is that you haven't yet created a package.json file.

To do this, run the following command.

$ npm init

However, if you don't want to answer the questions from running that command, run the following.

$ npm init -y

This will initialise the package.json file in your directory.


After you have done either of these solutions, then running the command below should work successfully.

$ npm install

CodePudding user response:

You need a package.json file in yor project you can run this command : npm init --yes

  • Related