Npm err code enoent ошибка

I’m suddenly having a problem with «npm start» in my React application. When I trigger it, this is what I receive:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/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!     /home/palnic/.npm/_logs/2020-02-20T11_30_39_463Z-debug.log

This is the debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.13.7
3 info using node@v12.13.1
4 verbose stack Error: ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
5 verbose cwd /mnt/c/Users/pal/Desktop/dev/myApp/package.json
6 verbose Linux 4.4.0-18362-Microsoft
7 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
8 verbose node v12.13.1
9 verbose npm  v6.13.7
10 error code ENOENT
11 error syscall open
12 error path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
13 error errno -2
14 error enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -2, true ]

I tried the following solution:

sudo npm install -g npm     //(ok!)
sudo npm cache clean   //(not working if not using --force flag)

And then npm install returns:

npm WARN saveError ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN myApp No description
npm WARN myApp No repository field.
npm WARN myApp No README data
npm WARN myApp No license field.

up to date in 0.454s
found 0 vulnerabilities

My npm version is: 6.13.7

This is my package.json

{
  "name": "myApp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.1",
    "firebase": "^7.7.0",
    "node-sass": "^4.13.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-redux": "^7.1.3",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "react-stripe-checkout": "^2.6.3",
    "redux": "^4.0.5",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "styled-components": "^5.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Do you have any ideas on the possible causes and the possible solutions?


Photo from Unsplash

When running npm commands from the terminal, you may get an error with code ENOENT.

Here’s an example of the error message log when running the npm start command:

$ npm start

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /nsebhastian/Desktop/DEV/n-app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open 
'/nsebhastian/Desktop/DEV/n-app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

As you can see, there’s an error with code ENOENT that prevents npm start command from running successfully.

The code ENOENT means that npm fails to open a file or directory that’s required for executing the command.

The npm start command is used to run the start script in the package.json file.

When the package.json file isn’t found, then npm throws the ENOENT error.

To fix the error, you need to make sure that the file or directory needed for running the command is available.

In the case above, adding a package.json file to the project will solve the error.

If that doesn’t work, then you probably don’t have a start script in your package.json file.

Learn more here: How to fix npm start command not working

Also, make sure that you are running the command from the project directory, right where the package.json file is located.

npm commands don’t work when you run them from a parent or child directory.

npm install fails with code ENOENT

The ENOENT error may also appear when you run the npm install command.

Here’s an example of the error:

$ npm install

npm ERR! path /Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 
'/Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates' -> '/Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/.delegates.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

The error above happens because you have a dependency that doesn’t install correctly.

Here are the steps to resolve this issue:

  • Make sure you are using the latest npm version
  • Clean your npm cache
  • Delete node_modules folder and package-lock.json
  • Run npm install again

Run the following commands one by one from the terminal:

# 👇 update npm to the latest version
npm install -g npm@latest

# 👇 clean npm cache
npm cache clean --force

# 👇 delete node modules and package-lock.json 
npm rm -rf node_modules && rm package-lock.json

# 👇 retry installing dependencies
npm install

The npm install command should now run successfully.

And that’s how you solve the npm error code ENOENT: no such file or directory error.

While I am trying to run my project with npm start command, then I am face the following error npm ERR! code ENOENT npm ERR! syscall open.

In this article, we will discuss about this npm ERR! code ENOENT npm ERR! syscall open error in ReactJs. And how to resolve the error all the possible solutions with examples.

How npm ERR! code ENOENT npm ERR! syscall open Error Occurs?

Most of the time you get this error while running your project with npm start command, looks like the below:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/codecary/Desktop/dev/myApp/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

How to fix npm ERR! code ENOENT npm ERR! syscall open?

There are different ways to fix npm ERR! code ENOENT npm ERR! syscall open this error. Let us take a look at every solution.

  • How to fix npm ERR! code ENOENT npm ERR! syscall open?

To Solve npm ERR! code ENOENT npm ERR! syscall open Error you have to check package.json in your project folder. if not available then try to create package-lock.json with this name. After npm install in your project folder and run npm. Then your error will be gone.

  • npm ERR! code ENOENT npm ERR! syscall open

To Solve npm ERR! code ENOENT npm ERR! syscall open You have to run your npm start at the root directory where your package.json file is located with this command: cd project-name. Now, your error will be solved.

Solution 1: Adding package.json

First you have to add package-lock.json file in your project folder.

package-lock.json

and Then run npm install.

npm install

Then, run npm.

npm start

Now, your error will be solved.

Solution 2: Run this command

You have to run your npm start your root directory where your package.json file is located.

cd project-name

Then do

npm install
npm start

Now, your error will be gone.

Conclusion

In this article, we have discussed what causes the error and we have discussed ways to fix the error.

we hope this article has been informative. Thank you for reading. Kindly comment and let us know if you found it helpful.

Учусь работать с vue cli.
При запуске команды npm run dev появляется ошибка:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path E:JS, HTML, CSSVuejs projectsAcademindpackage.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open ‘E:JS, HTML, CSSVuejs projectsAcademindpackage.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:UsersVasiliyAppDataRoamingnpm-cache_logs2020-07-28T18_38_07_389Z-debug.log

Note: I have managed to fight with this error, but if this can be of any help for debugging and making npm better, here’s my story… And plenty of logs, too.

I’m opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don’t understand.
  • Other (see below for feature requests):

What’s going wrong?

I was trying to install some dependencies. My package.json is well tested and, actually, identical one is running in a different directory just fine.

The error I’m getting:
ENOENT: no such file or directory, rename 'C:Userswojte.SURFACE-PRO-4Projektyreact-collision-detectortestnode_modulescreate-react-class' -> 'C:Userswojte.SURFACE-PRO-4Projektyreact-collision-detectortestnode_modules.create-react-class.DELETE'

Here’s my package.json file that fails to install
https://pastebin.com/3Fp6sKM7

And here’s the full log file:
https://1drv.ms/u/s!AuDm0u3ORBtMvLNa_YgXeY1csMYWsA

Notes:

  • the only interesting fact about my repo is that it refers to its parent folder (see line 17) to get one of the dependency (my repo is a test suite for another repo, placed in /test folder in it). However… ↙
  • two almost identical (npm-wise) repos I own install just fine
  • my parent repo has dependency react and react-dom both set to ">=15.5". The repo I’m having an issue with is set to next, which downloads as of now version 16.0.0-beta.5.
  • running npm install react@next produces the same error, heres the full log file: https://1drv.ms/u/s!AuDm0u3ORBtMvLNeY8b1ov67TcdiQA

I have tried the following:

  1. updating npm to the newest version — I was running 5.3.0 when I first saw the error.
  2. manually removing node_modules
  3. reinstalling npm and removing all its data in %appdata%.
    After reinstalling npm, I’ve installed parent repo again. Worked like a charm. Sadly, installing this repo failed again, here’s the full log file: https://1drv.ms/u/s!AuDm0u3ORBtMvLNdsT7TP91kO9no8Q
  4. removing package-lock.json files.
    After that, with clean state, I’ve run npm install on parent repo again. I got error: — Error: EPERM: operation not permitted, unlink.... I believe it’s connected to Error: EPERM: operation not permitted on npm 5.4 on windows #18380. Here’s the full log file: https://1drv.ms/u/s!AuDm0u3ORBtMvLNfelh0ppRVPWKxzA
  5. running npm in elevated command line
    That did not help and I still were getting suggestion to run command as root/Administrator.
  6. downgrading npm to 5.3.0
    That finally fixed it!

How can the CLI team reproduce the problem?

supporting information:

  • npm -v prints: 5.4.0
  • node -v prints: v8.3.0
  • npm config get registry prints: https://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Windows 10, build 16281
  • Network issues:
    • Geographic location where npm was run: Kraków, Poland
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don’t use a proxy, but have limited or unreliable internet access.
    • I use super good optic fiber 500 Mbps connection in Poland’s best internet provider
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).

Понравилась статья? Поделить с друзьями:
  • Nox player ошибка сервисов google play
  • Np 38551 2 ошибка ps4
  • Nox player ошибка разблокировки
  • Np 37614 1 ошибка ps4
  • Nox player ошибка при запуске игры