npm start does not work - node.js

npm start
npm ERR! path C:\WINDOWS\System32\WindowsPowerShell\v1.0\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\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\ATUL\AppData\Roaming\npm-cache\_logs\2017-10-01T10_20_21_068Z-debug.log
I am following the Wes-bos tutorial of learn-node. When I do npm start, it gives me these errors. Please help me. I have referred to all the previous questions. I am not able to find anything.

You have to run npm start in the root of the project you want to run, it seems you are runing npm start in a folder where there is not a package.json file.
The error says that you are running npm start in this path C:\WINDOWS\System32\WindowsPowerShell\v1.0\package.json but it seems that inside that folder you don't have a package.json file, so maybe you are in a wrong folder location.
So, if you downloaded some code to get started with, you should move to the root of that code and then run npm start.
If you are starting a new app, you have to run npm init first, that command will create a package.json file in the same location where you are in the console and then you will be able to run npm start.

I just had the same problem, so far I have never seen it.
But my solution was:
Rename the project folder (remove [], (), {} and special characters). Also try to remove spaces between words and if you continue the error try to join or just use (- or _) instead of space
Keep an eye on which folder is being performed. "When I didn't run: npm init -y" he would throw me to (C: \ WINDOWS \ System32 \ WindowsPowerShell \ v1.0 \ package.json), you don't want to run here,
use your project folder, change in the terminal to your folder: cd './c:\user\...\project'
Note: Solution tested in Windows - Visual Studio Code v1.56.0
nodejs vs-code visual-studio-code npm

Related

npm start command returns an error in the cmd

I want to start my React app, but when I run npm start, I get this error:
npm ERR! syscall open
npm ERR! path C:\Users\Muchendu\Documents\GitHub\Steve-React/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Muchendu\Documents\GitHub\Steve-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! C:\Users\Muchendu\AppData\Local\npm-cache\_logs\2022-05-11T09_26_37_201Z-debug-0.log
This could be because right after running
npx create-react-app <your_app_name>
you are trying to run npm start
Instead try switching into your app directory like so:
cd <your_app_name>
because that is where your package.json will most likely exist and then try running
npm start
run this command in the terminal inside your project npm init -y.
This will generate a package.json in your project.
Otherwise since you are making a react app use the npx create-react-app your-app-name this will create all the necessary files for running you application.
What is package.json?
The package.json file is the heart of any Node project. It records important metadata about a project which is required before publishing to NPM, and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.

Why "npm install -g grunt-cli" doesn't work correctly?

I am having trouble using grunt in my projects. I am setting up an macos computer with version 11.0.1.
The project files (local) are in principle correct, since I use it on another computer and it works fine there.
I have been trying to solve this error for more than two days, the problem is that the local configuration does not work correctly, since I get the message ~ bash: grunt command not found when trying to initialize grunt with the grunt or grunt watch command
When trying to install grunt-cli globally I get this error:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/bertanicolau/.npm-packages
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/bertanicolau/.npm-packages'
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/bertanicolau/.npm/_logs/2020-11-23T17_06_23_295Z-debug.log
The .npm-packages folder does not exist in this location, instead the .npm folder does exist, I don't know why it is looking for another.
I've tried clearing the npm cache, I've also tried deleting the package-lock.json file and changing paths on .bash-profile but none of this seems to work.
Can it be a npm or node version bug?
$ npm -v && node -v
7.0.8
v15.2.1
Thanks!
In one of your .npmrc files, you probably have prefix=/Users/trott/.npm-packages. If so, leave it and create the directory with mkdir ~/.npm-packages. Or set it to a different directory. Or remove the entry entirely.
The places to look for the .npmrc file that may be causing this to happen:
per-project config file (/path/to/my/project/.npmrc)
per-user config file (~/.npmrc)
global config file ($PREFIX/etc/npmrc)
npm builtin config file (/path/to/npm/npmrc)

Stuck on this error code ENOENT: no such file or directory, after trying to run "Hello World" exercise

I'm having some trouble trying to run the "Hello World" exercise from the PluralSight tutorial. I'm new to coding and I don't know what I'm doing wrong. I keep running into this error after entering the "npm run start" command in the terminal.
I looked up possible solutions online, but they all range from deleting and reinstalling the package.json file to reinstalling git and node.js, etc. I should note that I'm working on a Mac, so I don't know if that's also part of the issue or something.
Here's the code
charlierodriguez#Charlies-Mac-mini ~ % npm run start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/charlierodriguez/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/charlierodriguez/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/charlierodriguez/.npm/_logs/2020-11-23T17_59_28_824Z-debug.log
charlierodriguez#Charlies-Mac-mini ~ %
This error comes when npm is finding package.json file in that location and not able to find it. Can you run js npm init. It will create package.json file in that location.
You will still get some different error. As there should be a key start in script segment in package.json file.
You can add that key with the value as command you want to run.

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.

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!

Resources