npm: ENOENT no such file or directory - npm

I've looked at a few answers but cannot resolve this. I've completely removed Node from my system and reinstalled, but I still can't install any packages.
I get the following error every time:
npm WARN saveError ENOENT: no such file or directory, open '/Users/mattsaunders/Documents/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/mattsaunders/Documents/package.json'
npm -v shows 5.5.1
What is going on here?

It looks like you're not calling install from an npm project, so it can't find your package.json file

Related

unable to npm link a directory

I'm trying to npm link to a directory inside another project's node modules (as per this issue and workaround https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react where otherwise stuff doesn't work because a library I'm including also has a react)
What seems to be happening is even though I specify that the path has to have node_modules in side of it (see the first line for the input: sudo npm link ../../EicherDesignBuild/contractor-order-app/node_modules/react), somehow, npm link internally takes that part out (no such file or directory, open '/home/user/Documents/Dev/EicherDesignBuild/contractor-order-app/react/package.json')
(I have to do it with sudo, otherwise I'm getting a permissions error)
[user#work contractor-order-app]$ sudo npm link ../../EicherDesignBuild/contractor-order-app/node_modules/react
npm WARN tarball tarball data for react#file:react (null) seems to be corrupted. Trying again.
npm WARN tarball tarball data for react#file:react (null) seems to be corrupted. Trying again.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/user/Documents/Dev/EicherDesignBuild/contractor-order-app/react/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/user/Documents/Dev/EicherDesignBuild/contractor-order-app/react/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! /root/.npm/_logs/2022-07-16T19_24_44_703Z-debug-0.log
What is happening and why? How can I link this library?
npm version: 8.11.0
node version: v14.19.0

What is the reason for the npm installation error ENOENT: no such file or directory, open 'C:\Users\tusha\package.json'?

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
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.
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 inside
npm 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

NPM install not work and make lock-json file

Hi I'm trying to install npm to run a kit.
my node version is: v12.18.3
my npm version is: 6.14.6
my folder is "test" and I'm installing npm with this command:
Kian#DESKTOP-CL16DA7 MINGW64 /d/markitdone/test
$ npm install
npm WARN saveError ENOENT: no such file or directory, open 'D:\markitdone\test\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\markitdone\test\package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
up to date in 0.845s
found 0 vulnerabilities
Could someone help me please?
Before you use npm install.
You need to create a project, either React, Vue.js or Angular in your test directory

NPM Error code when trying to run npm start

I keep getting the npm ENOENT error when I try to run npm start. I'm not sure what to do to fix this issue.
I have tried to change permissions for folders.
bryantcaruthers-> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/bryantcaruthers/workshop-vs-code-can-do-that/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! /Users/bryantcaruthers/.npm/_logs/2019-11-06T03_31_38_233Z-debug.log
Be able to run npm start with no errors.
The error is that there is no package.json file in the directory you are running the code in:
no such file or directory, open /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json
Are you expecting a package.json file in that directory? Or should you be running npm start from somewhere else?
You can resolve that issue by following methods:
Ensure dependencies described correctly on package.json
Just run
npm install
Check issue still exists. and If issue not resolved, continue these methods.
npm cache clean
sudo npm install -g npm
npm cache clean
npm install
I found solution to this error. This error mostly occurs because you are not working on the right folder, cd to the right folder where you installed the npm or you can open the folder with vs code. For example, you have a main folder that contains the site or app folder, you need to be working from the subfolder and not the main folder, this is where you installed the npm and the dependencies are described correctly on package.json.
Your project workshop-vs-code-can-do-that does not have a packeage.json file available, to create it, go to terminal (on your project path), run this command
npm init -y
Encountered the same error.
Root Cause:
Not installing(npm i) and starting(npm start) from the correct path in terminal
Solution:
Change the directory to the application directory where package.json
present
hope this might help, Thanks.

Cannot start Electron application - missing package.json

I'm currently doing a Python project where I want to display my results in an Electron application. I have seen a demo video on YouTube on how to set up Electron on a Mac. The video showed 3 simple steps to be executed in the terminal:
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install && npm start
When I first ran the above commands it worked fine for me. I was able to start the Electron application.
But when I tried to re-start the application using the command npm start after going into the electron-quick-start directory, I am not able to open the application.
I am continuously getting an error message as follows:
(base) Viveks-MacBook-Pro:electron-quick-start vivekchowdary$ npm start
npm ERR! path /Users/vivekchowdary/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/vivekchowdary/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! /Users/vivekchowdary/.npm/_logs/2019-04-19T12_55_01_157Z-debug.log
(base) Viveks-MacBook-Pro:electron-quick-start vivekchowdary$
I don't know what it means? But I just want to open the Electron application.
As the error message states, the file package.json cannot be found.
One possible reason is that the terminal is not in the correct project folder and that you need to cd into the folder before running npm start.
If you cd to any folder that has no package.json (and whose parent folders don't have a package.json) and run npm start, you'll be presented with this error message.
Your specific file path seems to indicate that you ran npm start from your home folder, not the project folder that contains package.json.
I got a similar issue and I fixed it by creating the files it was asking for as well as a basic package.json file that my compiler generated for me