how to fix npm error in Mac in visual studio code - node.js

How do I fix this error?
USER#Bahus-MacBook-Air metaplex-master % npm --version
8\.5.2
USER#Bahus-MacBook-Air metaplex-master % npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/USER/Desktop/solana devnet/metaplex-master/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/USER/Desktop/solana devnet/metaplex-master/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/USER/.npm/\_logs/2022-03-24T13_07_17_630Z-debug-0.log
How do I fix this npm installation error in visual studio code in Mac?

The error message says that the path where you are executing npm i command doesn't have package.json file.
Make sure to change the path to the place where the package.json file is located.

I'm assuming you are trying this project https://github.com/metaplex-foundation/metaplex
And you are probably running npm install in the main directory. But if you read the instalation documentation which you definitely should, then you would see cd metaplex/js which means you need to run npm install within the ./js folder since that's where the package.json is, which is required by npm install command.

Related

How can I fix npm error running npm run build?

When I run npm run build, I had this error and I couldn't fix it reading all articles on github and same quest-s on stack:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Користувач\Desktop\test/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Користувач\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\Користувач\AppData\Local\npm-cache\_logs\2022-02-06T18_36_44_973Z-debug-0.log
Hi you are trying to run the build command in non node project please check whether you are in correct directory or not, if not please initialize the project by running npm init
ensure you're in the correct directory. You need to cd into the right directory before running the command.
If you want to make sure package.json is there in the directory, run
ls | grep package.json
if this doesn't show the file, then either you're in the wrong directory or you might have deleted package.json in which case you might have to recreate it, or bring it back from version control.

npm run serve failed

When I try to run "npm run serve" in my terminal on my Mac. I get following error message. It works fine for a couple a hours ago, but not now. can anyone help me?
npm ERR! syscall open
npm ERR! path /Users/MYNAME/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/MYNAME/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/MYNAME/.npm/_logs/2020-09-03T12_46_01_362Z-debug.log
First check on your filesystem if the file EXISTS.
for a new project, you always need to create a package.json, running
npm init
will create a package.json for you in the current directory.
if you want to instantly create a package.jsn using defaults, run
npm init -y
for more understanding refer this npm guide
If you say that everything worked before, then you are running this script in the wrong folder and npm cannot find package.json.
no such file or directory, open '/Users/MYNAME/package.json'
Use the correct folder.

NPM install current application globally (e.g. npm install -g .)

I am working on a package that is mean to be used globally and I want to install it globally before publishing it.
I've tried to use npm i -g . but it always fails due to files not being found
npm ERR! code ENOENT
npm ERR! syscall access
npm ERR! path /home/ivan/lux2/cli/node_modules/file-uri-to-path
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, access '/home/ivan/lux2/cli/node_modules/file-uri-to-path'
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! /home/ivan/.npm/_logs/2020-04-29T01_38_22_536Z-debug.log
I've tried this on a couple of different global npm package I'm working on all have the same result. I created a new package and it did work, is it something weird about the failing module (I've also seen bindings, nan and fsevents with this same error)
If I try creating those directories (they are not in my dependencies) I just end up finding more missing directories.
Any help would be appreciated.
Make sure you are running this command in a correct path and try to run command like this - npm install libraryName -g

React Application npm start is giving an error

I am trying to run my React app in the local environment and keep getting the following error
PS npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Documents\business-website-react-master\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\\Documents\business-website-react-master\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:\\_logs\2020-02-22T20_12_59_502Z-debug.log
Here is what the folder directory looks like as well.
the package.json file is still there so i don't understand why the file cannot be located.
Thank you in advance!
As the error message states, npm does not find package.json file. The reason in your case is that the file is located in the src folder. Once you move the file into the root - where you tried to run earlier - and run npm start then it should be just starting fine.
If the node_modules folder is also missing - which is containing all the installed dependencies to run your project - then you need to run first npm install which will take all the dependencies from package.json and install them.
I hope that helps!

Why there exist error when I run npm install --no-bin-links?

I use :
Laravel 5.4
Windows 10
Node version : v6.11.1
Npm version : 5.3.0
If I run : npm install --no-bin-links
There exist error :
npm WARN deprecated express#2.5.11: express 2.x series is deprecated
npm WARN deprecated connect#1.9.2: connect 1.x series is deprecated
npm ERR! path C:\xampp\htdocs\myshop\node_modules\bs-recipes
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\xampp\htdocs\myshop\node_modules\bs-recipes' -> 'C:\xampp\htdocs\myshop\node_modules\.bs-recipes.DELETE'
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\windows10\AppData\Roaming\npm-cache\_logs\2017-08-30T00_41_20_491Z-debug.log
How can I solve the error?
Update :
I uninstall Node version : v6.11.1 and install the new version, v8.4.0, but it's the same
I'm not familiar with this error but the console output clearly states:
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\xampp\htdocs\myshop\node_modules\bs-recipes' -> 'C:\xampp\htdocs\myshop\node_modules\.bs-recipes.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
Try the following:
Restart your computer.
If you are using visual studio code, close it. And run npm install via console.
If you are using visual studio code, update it to the latest version.
Find that file in the error and rename it, as the error suggests.
Tip: Always read the error message. Most of the time it will tell you what the problem exactly is.
Update
Try checking this similar issue on github: npm 17444

Resources