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 andpackage-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.
Учусь работать с 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
andreact-dom
both set to">=15.5"
. The repo I’m having an issue with is set tonext
, 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:
- updating npm to the newest version — I was running 5.3.0 when I first saw the error.
- manually removing node_modules
- 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 - removing package-lock.json files.
After that, with clean state, I’ve runnpm 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 - running npm in elevated command line
That did not help and I still were getting suggestion to run command as root/Administrator. - 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.0node -v
prints: v8.3.0npm 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).
I recently struggled for a while with an npm
error thrown when executing npm install
of some package. The error message was npm ERR! enoent ENOENT: no such file or directory, rename 'D:\WebApp\node_modules\lz-string' -> 'D:\WebApp\node_modules.lz-string.DELETE'
Finally, I found a solution and a reason for that issue.
The error occurred when I was trying to install @testing-library/react
npm package. It looked like that:
Hotfix
If you ever get this error, the hotfix is to follow these steps:
- delete
node-modules
folder - run command
npm cache clean --force
- run command
npm install
- install the package again with
npm install your-package-name
It should all work fine after that.
If these commands still don’t solve your issue, and you use git
as a source control system, you can try the unbeatable git clean -fdx
command. After that, run npm install
again. Beware – it removes all files not checked in to git. It may also remove your IDE settings etc., so use with care.
But it’s only a hotfix, a solution for now to unblock you.
Coldfix (solution)
The real reason for this issue in my case turned out to be related to jest
. However, not to the testing library itself, but to jest extension for Visual Studio Code.
The reason for the issue is the jest tests runner working in the background. You can see that in the VS Code bottom bar:
The real solution is to disable jest runner when installing new packages. You can do it with a Jest: Stop Runner
command in Ctrl+Shift+P:
I don’t know exactly why this is an issue. I guess jest runner is blocking some files in node-modules
, so they cannot be renamed/processed. I hope it helps you too 😉
Introduction
Recently, I’ve faced different issues when tryng npm install
in some of the project I’ve been working with.
Environment
- Windows 10 (OS Build 15063.413)
- Node version: 8.1.2
- NPM version: 5.0.3
Every time I tried npm install or install a isolated package I got errors like this one:
Problem
1 |
_npm ERR! path GitHubreact-typescript-webpack2-cssModules-postCSSnode_modulests-loader |
Solution
The solution for my specific scenario was:
1. Close VS Code
2. Remove package-lock.json, node_modules and npm cache
1 |
|
1 |
|
3. Retry npm i
Read more…
If you still have this problem, read this: https://github.com/npm/npm/issues/10826
Copyright Notice: All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.
I am trying to run my project with npm start but It failing with the following error: npm ERR! code ENOENT npm ERR! syscall open in ReactJS. In this Exerror article, We are going to learn about How to reproduce this error and we will discuss All Possible Solutions Let’s Get Started with This Article.
Contents
- How npm ERR! code ENOENT npm ERR! syscall open Error Occurs?
- How To Solve npm ERR! code ENOENT npm ERR! syscall open Error?
- Solution 1: run in root of your project
- Solution 2: run this command
- Solution 3: Simple Example
- Conclusion
How npm ERR! code ENOENT npm ERR! syscall open Error Occurs?
I am trying to run my project with npm start but It failing with the following error.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path F:ReactJS Projectmy_apppackage.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open 'F:ReactJS Projectmy_apppackage.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
So here I am writing all the possible solutions I have tried to resolve this error.
How To Solve npm ERR! code ENOENT npm ERR! syscall open Error?
- How To Solve npm ERR! code ENOENT npm ERR! syscall open Error?
To Solve npm ERR! code ENOENT npm ERR! syscall open Error You Just need to run your project at the root of your for example my project name is my_app first of all go into your project: cd my_app and Then run npm install: npm install Then, you can run your project just like this: npm start And Now, your error is resolved thank you.
- npm ERR! code ENOENT npm ERR! syscall open
To Solve npm ERR! code ENOENT npm ERR! syscall open Error You Just need to run your project at the root of your for example my project name is my_app first of all go into your project: cd my_app and Then run npm install: npm install Then, you can run your project just like this: npm start And Now, your error is resolved thank you.
Solution 1: run in root of your project
You Just need to run your project at the root of your for example my project name is my_app first of all go into your project.
cd my_app
and Then run npm install.
npm install
Then, you can run your project just like this.
npm start
And Now, your error is resolved thank you.
Solution 2: run this command
This error usually occurs whenever you are trying to run npm start outside of your project. You need to run your npm start at the root of your project where your package.json file is located.
cd your_project_name
npm start
Now, your error must be solved.
Solution 3: Simple Example
Suppose My project is located at F:ReactJS Projectmy_app and I am running npm start from F:ReactJS Project then I will Face npm ERR! code ENOENT npm ERR! syscall open this error. I need to run my npm start from F:ReactJS Projectmy_app and then my error will be solved.
Conclusion
It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
- How to update all dependencies in package.json to the latest version
- ReferenceError: document is not defined in Nextjs
- ChromeDriverManager().install() Is Giving KeyError: ‘google-chrome’
- AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_css_selector’
- Command link unrecognized in React Native