I try to install libraries with npm on Windows to work with JavaScript, but it shows this error output in Windows command prompt window:
C:\Users\tusha>npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\tusha/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\tusha\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\tusha\AppData\Local\npm-cache\_logs\2022-04-24T10_37_38_185Z-debug-0.log
C:\Users\tusha>
Here is also a photo:
Screen shot of command prompt window with the error output
The log of the failed installation process:
The complete log file on Google Drive
CodePudding user response:
ERR telling that in your folder directory you are installing some packages through npm. Look like package.json not found in located directory
Before run npm install
to empty folder you have to initialize the npm init
to create package.json file. and start installing packages.
CodePudding user response:
npm install
reads the file package.json from the current directory and installs all the packages it depends on. The error message says that there is no such file.
You need to cd
to the directory the Node.js project (e.g. something you might have checked out from a Git repository) and run npm install
there.
Alternatively, if you are trying to install a specific package from the npm repository then you need to:
cd
to the directory containing the package you want to add it as a dependency of- run
npm install name-of-package
If you don't have a project yet, and want to create one, then:
cd
to the directory you want to create your package insidenpm init
and follow the prompts
Alternatively, if you are trying to install a program from npm globally then reconsider as current best practice is to run program with npx
and not install them as globals. Use the name of the package you want to run as an argument.
npx create-react-app
If you really want to install globally, then use the -g
switch and the name of the package.
npm install -g create-react-app