Error enoent no such file or directory open etc ksc web console setup json

Fix Nodejs Error: ENOENT: no such file or directory This tutorial guides you on how to fix Nodejs Error: ENOENT: no such file or directory while running your node project or any application which contains Nodejs component. Fix Nodejs Error: ENOENT: no such file or directory When I tried to download guacamole-client whose frontend […]

Содержание

  1. Fix Nodejs Error: ENOENT: no such file or directory
  2. Fix Nodejs Error: ENOENT: no such file or directory
  3. Solution
  4. ENOENT: no such file or directory .?
  5. 27 Answers 27
  6. Error message «ENOENT, no such file or directory»
  7. 17 Answers 17
  8. How to resolve Node.js: «Error: ENOENT: no such file or directory»
  9. 26 Answers 26

Fix Nodejs Error: ENOENT: no such file or directory

This tutorial guides you on how to fix Nodejs Error: ENOENT: no such file or directory while running your node project or any application which contains Nodejs component.

Fix Nodejs Error: ENOENT: no such file or directory

When I tried to download guacamole-client whose frontend is developed using Nodejs, and I tried to setup installing guacamole natively on Windows machine.

After downloading the code, I was trying to build guacamole-client which includes Nodejs frontend component by running “mvn package” command as shown below. But it resulted with error “ Error: ENOENT: no such file or directory, open ‘C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontenddistnpm-dependencies.txt’

The above command “mvn package” is supposed to invoke maven to automatically build and package all the components, producing a single .war file. And while building frontend Nodejs component, it was looking for a file called “npm-depedencies.txt” but that file is missing.

Solution

As you can see from the above error, that it is expecting file called “npm-dependencies.txt” to be there in specific path. But it does not exist.

ENOENT means Error NO ENTry (or Error NO ENTity) or simply you can say that there is NO such directory ENTry.

Therefore, you either need to create the expected file in the specific path i.e., under dist directory or else reconfigure your application so that it will point to the correct directory path for the required file.

After fixing, try building your application again. The Nodejs Error: ENOENT: no such file or directory should have gone away now.

Источник

ENOENT: no such file or directory .?

This is error which am getting while post data and file. I have followed ‘academind’ tutorial for building Restful API services, also i have been searching answer for this type of errors but nothing works for me.

Am using «multer» to upload file

The folder ‘uploads’ available in the folder but it shows

ENOENT: no such file or directory, open ‘D:projectuploads2018-01-24T07:41:21.832Zcheck.jpg’»

27 Answers 27

After new Date().toISOString() add replace() to change «:» to an accepted character.

Windows OS doesn’t accept files with a «:»

The person on Youtube is using MAC OS

Try the following:

    Require this as a constant (const path = require(‘path’);)

Change this line

As I can see, you are trying to get a path that is not on served on the server, but rather a path that is on the server machine.

UPDATE

Try also changing this

In order to expose the __dirname for static files.

This what worked for me. I changed ‘./uploads/’ into ‘__dirname’ so that it can find the correct directory/filename anywhere on your computer.

Because when you set a specific folder name/directory you limit your image directory to be only or should be in that folder.

So the answer is in the tutorials comments section on youtube. Instead of:

I am doing the same course and I too had the same problem (i also use windows machine). The following worked for me:

This creates a unique hash for the filenames as well

OK guys, in case someone has an issue with this in the file creation stage, that probably means you’re working on Windows. Now, you don’t need to feel discouraged and throw your computer to the trash (I actually like always having to find workarounds for my Windows :).

There’s at least a solution, and this is the one I found. My problem is the file does not get created because Windows does not accept filenames with colon (‘:’) on it. My solution is rather simple. After I get the current date, I use replace() and a regexp to change that into a dash. Viola. It works!

Hope it helps someone who´s working in windows.

I came across the same error while saving the file. The path I provided in callback didn’t exist already that’s why I got that error

With filesystem I created the same folder, In case of folder exists the err gets value but here nothing to worry about as we have that folder. This worked for me. hope this would help

Источник

Error message «ENOENT, no such file or directory»

I’m getting this error from my Node.js application:

ENOENT, no such file or directory ‘

I know the file is there because when I try to open the file using the exact copied and pasted path, it works. I also know the application is using the right directory because, well, it outputs it in the error.

17 Answers 17

I believe the previous answer is the correct answer to this problem but I was getting this error when I tried installing npm package (see below):

The fix for me was: npm init —yes

Tilde expansion is a shell thing. Write the proper pathname (probably /home/ yourusername /Desktop/etcetcetc ) or use
process.env.HOME + ‘/Desktop/blahblahblah’

/Desktop/BitBox/thenewbox’; I tried app.set(‘home’, process.env.HOME || ‘/Users/Kinnard/Desktop/BitBox/thenewbox’); But that didn’t work, same error.

/Desktop/BitBox/thenewbox’; to the absolute path worked. Thanks!

  1. First try npm install . If the issue is not yet fixed, try the following one after the other.
  2. npm cache clean , then
  3. npm install -g npm , then npm install . Finally
  4. ng serve —o to run the project.

I was also plagued by this error, and after trying all the other answers, magically found the following solution:

Delete file package-lock.json and the node_modules folder, and then run npm install again.

If that doesn’t work, try running these in order:

(taken from @Thisuri’s answer and @Mathias Falci’s comment respectively)

And then re-deleting the above files and rerunning npm install .

It worked for me!

Gives you the current Node.js application’s root directory.

In your case, you’d use

See this answer:

I had that issue using the path module:

And also do not forget to create the uploads directory first period.

Specifically, rm yarn.lock and then yarn install fixed this for me.

For those running Laravel Mix with npm run watch , just terminate the script and run the command again.

For me, it had my code folder in Dropbox on Windows 10. During the build process Dropbox would flip out over having more than 500,000 files. I moved my folder out and now it builds fine!

Источник

How to resolve Node.js: «Error: ENOENT: no such file or directory»

I have a Node.js web application currently running on a server successfully. Now I’m trying to set up a local copy on my development server.

I currently have Node.js, NPM and MongoDB Installed just like what I have in production server. However, the error below occurs when I try to start the Node.js server.

What could be causing this issue?

26 Answers 26

Your app is expecting to find a file at /home/embah/node/nodeapp/config/config.json but that file does not exist (which is what ENOENT means). So you either need to create the expected directory structure or else configure your application such that it looks in the correct directory for config.json .

After going through so many links and threads and getting frustrated over and over again, I went to the basics and boom! it helped. I simply did:

I don’t know, but it might help someone 🙂

92% additional asset processing scripts-webpack-plugin× 「wdm」: Error: ENOENT: no such file or directory, open.

If anyone faced to such an error, you should do followings:

you should check if the file path is correct in the angular.json file.

«scripts»: [ «node_modules/jquery/dist/jquery.min.js», «node_modules/bootstrap/dist/js/bootstrap.js» ],

you should press Ctrl + C and rerun the project.

olleh’s answer worked, because npm install will create a node_modules directory in the current path where it is executed. So, while using the file server system module, the below declaration locate files from the top level directory of node_modules .

In my case the issue was caused by using a file path starting at the directory where the script was executing rather than at the root of the project.

My directory stucture was like this: projectfolder/ ├── package.json ├── scriptFolder/ │ ├── myScript.js

And I was calling fs.createReadStream(‘users.csv’) instead of the correct fs.createReadStream(‘scriptFolder/users.csv’)

If you have the same error while using Express.js in your project this worked for me:

In my project, when I ran an Express.js application, I noticed that the current working directory was the root directory of the project (while I was trying to read a file that was located in the script’s directory). It could not run the file since process.cwd() !== __dirname .

You can check it out and console log process.cwd() in the script you are trying to read the JSON file with.

I just changed the path to:

I also had this issue, because I had another console window open that was running the application and I was attempting to rerun yarn start in another console window.

The first Yarn executing prevented the second from writing. So I just killed the first process and it worked.

In my case, the issue occurred after I switched from a Git branch to another, references to some old files remained in the scripts inside the «node_modules/.cache» directory.

Deleting the «node_modules», «build» directories and «package-lock.json» file and then issuing the «npm install» command has fixed the issue for me.

I solved this error by simply creating a blank file at that location for which I got the error. If you are getting the error for a directory, you can try by also creating an empty directory.

If there isn’t any layout folder, just use it like this in your routing:

Here change something with your folder name.

I was facing this issue with ng-package.json file, while creating a plugin. I found out I was providing the wrong path in angular.json . Fixed my file path, issue was resolved.

May be helpful for someone.

Make sure your angular.json file has the «style» and «scripts» array as below (for Angular 12 and above):

Once this is done, press Ctrl + C and then ng serve .

I don’t know if anyone would see this, but I’ll say my answer.

First you need to be in the app directory that you created with the following command:

to make it install all dependencies from

and make sure to run them with the sudo command, because sometimes it is absolutely necessary.

I added the PM2_HOME environment variable on the system level and now it works all right.

in that order in the terminal solved the issue for me.

If you’re coding with TypeScript, remember that the transpiled-JS folder is where JavaScript would be searching for your file and will definitely not be able to find your html-file; hence such error.

Therefore, you’d need to copy the file into the transpiledJS folder for it to be located.

But for me, I also have to create a public folder in the server folder. It’s like -cb(null,’public/’) .

Sometimes you see this issue in the following scenario.

Let’s assume that you have a folder structure like node-projects (folder) → my-blog (folder) → my-blog (folder where the actual project exists), but you are in the my-blog directly, and it is an immediate child of node-project . Try to run your command in that directory.

As the project is present in my-blog that is an immediate child of my-blog . So, in this case, it searches your config.json file in my-blog (which is an immediate child of node-projects ) rather than finding the config.json file in my-blog that is an immediate child of my-blog .

Just transfer your directory by hitting the command cd my-blog in your terminal and that’s it. The problem is resolved!

Источник

I have a Node.js web application currently running on a server successfully. Now I’m trying to set up a local copy on my development server.

I currently have Node.js, NPM and MongoDB Installed just like what I have in production server. However, the error below occurs when I try to start the Node.js server.

What could be causing this issue?

cd ~/node/nodeapp
node app.js

Output:

fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/home/embah/node/nodeapp/config/c
onfig.json'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Object.<anonymous> (/home/embah/node/nodeapp/config/config.js:4:28)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/embah/node/glorby/app.js:13:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

Peter Mortensen's user avatar

asked Apr 6, 2017 at 16:19

Emeka Mbah's user avatar

1

Your app is expecting to find a file at /home/embah/node/nodeapp/config/config.json but that file does not exist (which is what ENOENT means). So you either need to create the expected directory structure or else configure your application such that it looks in the correct directory for config.json.

answered Apr 6, 2017 at 16:23

Trott's user avatar

TrottTrott

64k22 gold badges166 silver badges206 bronze badges

0

After going through so many links and threads and getting frustrated over and over again, I went to the basics and boom! it helped. I simply did:

npm install

I don’t know, but it might help someone :)

answered Jun 16, 2018 at 21:15

olleh's user avatar

olleholleh

1,80618 silver badges21 bronze badges

5

Regarding:

92% additional asset processing scripts-webpack-plugin× 「wdm」: Error: ENOENT: no such file or directory, open….

If anyone faced to such an error, you should do followings:

  1. you should check if the file path is correct in the angular.json file.

    «scripts»: [
    «node_modules/jquery/dist/jquery.min.js»,
    «node_modules/bootstrap/dist/js/bootstrap.js»
    ],

  2. you should press Ctrl + C and rerun the project.

Peter Mortensen's user avatar

answered Jun 27, 2019 at 16:10

Odiljon Djamalov's user avatar

1

olleh’s answer worked, because npm install will create a node_modules directory in the current path where it is executed. So, while using the file server system module, the below declaration locate files from the top level directory of node_modules.

const fs = require('fs')

Peter Mortensen's user avatar

answered May 7, 2019 at 23:27

Aniruddha Pandey's user avatar

In my case the issue was caused by using a file path starting at the directory where the script was executing rather than at the root of the project.

My directory stucture was like this:
projectfolder/
├── package.json
├── scriptFolder/
│ ├── myScript.js

And I was calling fs.createReadStream('users.csv') instead of the correct fs.createReadStream('scriptFolder/users.csv')

answered Jun 15, 2020 at 22:55

Chase Denecke's user avatar

0

If you have the same error while using Express.js in your project this worked for me:

In my project, when I ran an Express.js application, I noticed that the current working directory was the root directory of the project (while I was trying to read a file that was located in the script’s directory).
It could not run the file since process.cwd() !== __dirname.

You can check it out and console log process.cwd() in the script you are trying to read the JSON file with.

I just changed the path to:

const fs = require('fs');
fs.readFileSync(`${__dirname}\FILENAME`);

Peter Mortensen's user avatar

answered Jan 29, 2022 at 20:20

Niv's user avatar

NivNiv

4456 silver badges16 bronze badges

I also had this issue, because I had another console window open that was running the application and I was attempting to rerun yarn start in another console window.

The first Yarn executing prevented the second from writing. So I just killed the first process and it worked.

Peter Mortensen's user avatar

answered May 15, 2018 at 8:24

Damian Green's user avatar

Damian GreenDamian Green

6,6062 gold badges31 silver badges42 bronze badges

1

In my case, the issue occurred after I switched from a Git branch to another, references to some old files remained in the scripts inside the «node_modules/.cache» directory.

Deleting the «node_modules», «build» directories and «package-lock.json» file and then issuing the «npm install» command has fixed the issue for me.

Peter Mortensen's user avatar

answered May 18, 2020 at 12:29

Hasnaa Ibraheem's user avatar

Hasnaa IbraheemHasnaa Ibraheem

1,0721 gold badge10 silver badges16 bronze badges

1

I solved this error by simply creating a blank file at that location for which I got the error. If you are getting the error for a directory, you can try by also creating an empty directory.

Peter Mortensen's user avatar

answered Jun 13, 2020 at 17:58

sanghamitra Ravi Kant's user avatar

0

If there isn’t any layout folder, just use it like this in your routing:

app.get('/', (req, res) => {
    res.render('something', { layout: false });
})

Here change something with your folder name.

Peter Mortensen's user avatar

answered Jun 27, 2020 at 6:10

MD.FAHIM HOSSEN's user avatar

0

I was facing this issue with ng-package.json file, while creating a plugin. I found out I was providing the wrong path in angular.json. Fixed my file path, issue was resolved.

May be helpful for someone.

answered Mar 24, 2021 at 10:06

Analyst's user avatar

AnalystAnalyst

6816 silver badges14 bronze badges

Make sure your angular.json file has the «style» and «scripts» array as below (for Angular 12 and above):

"styles": [
          "src/styles.css",
          "./node_modules/bootstrap/dist/css/bootstrap.css"
        ],
"scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.js"
        ]

Once this is done, press Ctrl + C and then ng serve.

Peter Mortensen's user avatar

answered Jun 24, 2021 at 5:17

Ratnesh Rai's user avatar

I don’t know if anyone would see this, but I’ll say my answer.

First you need to be in the app directory that you created with the following command:

npx create-react-app [app-name]

Next run:

sudo npm install

to make it install all dependencies from

package.json

Then run:

sudo npm start

and make sure to run them with the sudo command, because sometimes it is absolutely necessary.

Peter Mortensen's user avatar

answered Dec 5, 2021 at 18:23

Javad's user avatar

JavadJavad

1731 silver badge9 bronze badges

1

I added the PM2_HOME environment variable on the system level and now it works all right.

Peter Mortensen's user avatar

answered Nov 2, 2020 at 15:27

kepy97's user avatar

kepy97kepy97

95010 silver badges12 bronze badges

1

Running

npm run scss
npm run start 

in that order in the terminal solved the issue for me.

Peter Mortensen's user avatar

answered Mar 11, 2020 at 11:44

Onat Korucu's user avatar

Onat KorucuOnat Korucu

91411 silver badges13 bronze badges

1

If you’re coding with TypeScript, remember that the transpiled-JS folder is where JavaScript would be searching for your file and will definitely not be able to find your html-file; hence such error.

Therefore, you’d need to copy the file into the transpiledJS folder for it to be located.

Peter Mortensen's user avatar

answered Nov 15, 2021 at 13:30

Chukwunazaekpere's user avatar

Sometimes you see this issue in the following scenario.

Let’s assume that you have a folder structure like node-projects (folder) → my-blog (folder) → my-blog (folder where the actual project exists), but you are in the my-blog directly, and it is an immediate child of node-project. Try to run your command in that directory.

As the project is present in my-blog that is an immediate child of my-blog. So, in this case, it searches your config.json file in my-blog (which is an immediate child of node-projects) rather than finding the config.json file in my-blog that is an immediate child of my-blog.

Just transfer your directory by hitting the command cd my-blog in your terminal and that’s it. The problem is resolved!

Peter Mortensen's user avatar

answered Oct 18, 2022 at 21:27

HamzaKhalid273's user avatar

HamzaKhalid273HamzaKhalid273

1971 gold badge1 silver badge11 bronze badges

Weirdly, in my project, I always get this error first time I add/remove a package, but then I run the same command again and it works on the second run.

answered Apr 25, 2022 at 14:59

Michal Kurz's user avatar

Michal KurzMichal Kurz

1,31210 silver badges33 bronze badges

My mistake was not adding / before the path. Correct path: /Users/mee/Documents/file_name.jpg

answered Oct 11, 2022 at 4:58

GorvGoyl's user avatar

GorvGoylGorvGoyl

38.6k26 gold badges213 silver badges204 bronze badges

I had a Node.js version mismatch. Installing the right version of Node.js via nvm worked.

Peter Mortensen's user avatar

answered Feb 8, 2022 at 16:48

LukeWarm2897's user avatar

I had this error while uninstalling Bootstrap from the project, so I just deleted the script and style from file angular.json.

"styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
 "scripts": [
              "node_modules/jquery/dist/jquery.min.js"
          ]

Cleared this to

"styles"  : [    ],
"scripts" : [    ]

This solved my issue.

Peter Mortensen's user avatar

answered Jul 19, 2022 at 6:38

saurabh solanke's user avatar

I work with Visual Studio Code, Git and Nx and often have the problem that Visual Studio Code performs an auto staging.

In combination with Nx, it comes very often to problems. Simply unstaging the files in Visual Studio Code often helps.

answered Feb 25, 2022 at 12:36

TimJ0212's user avatar

TimJ0212TimJ0212

111 silver badge2 bronze badges

1

In my case

import { Object } from '../config/env';

gave me the error.

I solved it with change the address like this:

import { Object } from './../config/env';

answered Apr 24, 2019 at 13:40

msalihbindak's user avatar

It’s happened with me. I deleted some CSS files by mistake and then copied back. This error appeared at that time. So I restarted all my Docker images and other servers and then it went away.

Peter Mortensen's user avatar

answered Apr 3, 2019 at 11:35

Yasir Akbar's user avatar

I tried something and got this error:

Error: ENOENT: no such file or directory, open ‘D:WebsiteNodemailerNodemailer-applicationviewslayoutsmain.handlebars’

The fix I got was to literally construct the directory as it is seen. This means labeling the items exactly as shown. It is weird that I gave the computer what it wanted.

Peter Mortensen's user avatar

answered May 25, 2020 at 19:53

Blank456's user avatar

1

@jshbrntt

I installed supertest before installing debug and it fixed this error.

Maybe make it a dependency of this module?

@mooyoul

No. That’s not an issue of debug package.
I think it’s related to NPM v3’s changed installation behavior.

You can resolve that issue by following methods:

  1. Ensure dependencies described correctly on package.json
  2. Just type npm install and hit Enter.
  3. Check issue still exists. and If issue not resolved, continue these methods.
  4. type npm cache clean and hit Enter
  5. type sudo npm install -g npm and hit Enter.
  6. Retry npm install and hit Enter.

if issue not resolved even tried these methods, Please reply with your Node.js version, NPM version, Operating System, and package.json which is using.

lubronzhan, IgnacioGaldames, 2hangying, xmaimom, nkhem, fredriikolsson, zoom2manoj, jbora201, xgqfrms-GitHub, owgee, and 36 more reacted with thumbs up emoji
xgqfrms-GitHub, AprilTong, yyfsyw, isrvamsi, ordsec, jorditambillo, gkarmas, kika-deploy, alexreyes, sundoze, and 2 more reacted with laugh emoji
IgnacioGaldames, davidreact, Wajahat-Hussain, xmaimom, jmizrachi, fredriikolsson, Bogdan323, xgqfrms-GitHub, RichardChiang, nakhhuan, and 11 more reacted with hooray emoji
devope reacted with confused emoji
xgqfrms-GitHub, yolisa, rawairawai, yyfsyw, cameck, jacktnugent, gkarmas, alexreyes, sundoze, deivoff, and 3 more reacted with heart emoji

@FaShapouri

@mooyoul I have that problem and tried your solution. But my problem did not resolve.
I am using mac os 10.11.4 and Node 6.2.2 and npm 3.9.5

The node_modules is in user/muser/node_modules/
I see mysql package in this folder
But when I try nam install, below message appears on terminal:

npm WARN enoent ENOENT: no such file or directory, open '/Users/muser/package.json'
npm WARN muser No description
npm WARN muser No repository field.
npm WARN muser No README data
npm WARN muser No license field.

There is no package.json at '/Users/muser/package.json'

What is wrong in my setup? and how can I fix it.

@mooyoul

@FaShapouri It seems trying npm install in uninitialized npm package directory.
you should initialize package with npm init.
If you want to use debug without package initialize, just use npm install debug.

srebalaji, sanjeevkse, goonerDp, virgil, rubykv, FaShapouri, anirudhmurali, anilmuppalla, andrejgodina, pjm4, and 43 more reacted with thumbs up emoji
Kriel, oumou318, kaleem-elahi, EliVerbrugge, alexreyes, Nako68l, and zrhth5 reacted with laugh emoji
zrhth5 reacted with hooray emoji
Jay25patil, kaleem-elahi, smoliakov, adilbekes, alexreyes, and zhaolinnan12 reacted with confused emoji

@Okezie

Simply try npm install npm@latest -g it worked for me cheers.

Jay25patil, apbraga, amaljose01, cferrante, sheetal-mandyal, caiosist, evawyf, WIZARDELF, pt657407064, mmiinnovations, and 14 more reacted with thumbs up emoji
purefan reacted with thumbs down emoji

@TooTallNate

This module does not use supertest, and thus is not an issue for debug. Closing.

@mriscoramdani

Try to change your node.js version

@osa9j

i am having problem installing npm …it keep getting this:
npm WARN enoent ENOENT: no such file or directory, open ‘/Users/jamesosaedebiri/package.json’

@dylannirvana

Indeed what it wants is a package.json file, obtained by typing npm init. Then I was able to do an npm install with success.

@anilkumarsoni

WARN enoent ENOENT: no such file or directory, open ‘/home/nodeuser/hapi-mysql-unchained/node_modules/request/package.json’
npm WARN hapi-mysql-unchained@1.0.0 No description
npm WARN hapi-mysql-unchained@1.0.0 No repository field.
npm ERR! Linux 4.4.0-36-generic
npm ERR! argv «/usr/bin/nodejs» «/usr/bin/npm» «install»
npm ERR! node v6.9.2
npm ERR! npm v4.2.0
npm ERR! path /home/nodeuser/hapi-mysql-unchained/node_modules/node-pre-gyp/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access ‘/home/nodeuser/hapi-mysql-unchained/node_modules/node-pre-gyp/node_modules’
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access ‘/home/nodeuser/hapi-mysql-unchained/node_modules/node-pre-gyp/node_modules’
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘access’,
npm ERR! path: ‘/home/nodeuser/hapi-mysql-unchained/node_modules/node-pre-gyp/node_modules’ }

@mukun-bhatta

  1. node.js version — v7.7.1
  2. npm version — 4.3.0
  3. operating system ubuntu 14.04
  4. package.json at /home/faltu/package.json is not there

@shmooth

if you are pretty new to Node/github/etc., you might be doing what I did — cloned a repo and then forgot to cd into the repo directory — so npm can’t find a package.json file, so it gives you that big convoluted error message.

i was operating in my main ‘dev’ directory:

~/dev$ npm install

but i needed to be in my cloned git directory:

~/dev/quiztool$ npm install

sakjawea, raushan896, dwenaus, simeyla, alexreyes, WPAS, and d88naimi reacted with thumbs up emoji
EdwardPerello, alexreyes, and d88naimi reacted with hooray emoji
EdwardPerello, alexreyes, and d88naimi reacted with heart emoji

@MarcioDuran

ubuntu@ubuntu:~$ npm install debug
npm ERR! Linux 4.8.0-22-generic
npm ERR! argv «/home/ubuntu/.nvm/versions/node/v7.7.2/bin/node» «/home/ubuntu/.nvm/versions/node/v7.7.2/bin/npm» «install» «debug»
npm ERR! node v7.7.2
npm ERR! npm v4.1.2
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’

npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/npm-debug.log

@sudosoph

@sudosoph

@WJLkalin

you can try «npm install -g bootstrap@4.0.0-alpha.6», i did it successfully in this way.

@amaljose01

Please try, npm install npm@latest -g

the output you will get as below

C:Users*AppDataRoamingnpmnpm -> C:Users*AppDataRoamingnpmnode_modulesnpmbinnpm-cli.js
C:Users*****AppDataRoamingnpm
-- npm@4.4.4 +-- abbrev@1.1.0 +-- ansi-regex@2.1.1 +-- ansicolors@0.3.2 +-- ansistyles@0.1.3 +-- aproba@1.1.1 +-- archy@1.0.0 +-- asap@2.0.5 +-- bluebird@3.5.0 +-- call-limit@1.1.0 +-- chownr@1.0.1 +-- cmd-shim@2.0.2 +-- columnify@1.5.4 | — wcwidth@1.0.0
| -- defaults@1.0.3 | — clone@1.0.2
+— config-chain@1.1.11
| -- proto-list@1.2.4 +-- debuglog@1.0.1 +-- dezalgo@1.0.3 +-- editor@1.0.0 +-- fs-vacuum@1.2.10 +-- fs-write-stream-atomic@1.0.10 +-- fstream@1.0.11 +-- fstream-npm@1.2.0 | — fstream-ignore@1.0.5
| -- minimatch@3.0.3 | — brace-expansion@1.1.6
| +— balanced-match@0.4.2
| -- concat-map@0.0.1 +-- glob@7.1.1 | +-- fs.realpath@1.0.0 | +-- minimatch@3.0.3 | | — brace-expansion@1.1.6
| | +— balanced-match@0.4.2
| | -- concat-map@0.0.1 | — path-is-absolute@1.0.1
+— graceful-fs@4.1.11
+— has-unicode@2.0.1
+— hosted-git-info@2.2.0
+— iferr@0.1.5
+— imurmurhash@0.1.4
+— inflight@1.0.6
+— inherits@2.0.3
+— ini@1.3.4
+— init-package-json@1.9.5
| -- promzard@0.3.0 +-- JSONStream@1.3.1 | +-- jsonparse@1.3.0 | — through@2.3.8
+— lazy-property@1.0.0
+— lockfile@1.0.3
+— lodash._baseindexof@3.1.0
+— lodash._baseuniq@4.6.0
| +— lodash._createset@4.0.3
| -- lodash._root@3.0.1 +-- lodash._bindcallback@3.0.1 +-- lodash._cacheindexof@3.0.2 +-- lodash._createcache@3.1.2 +-- lodash._getnative@3.9.1 +-- lodash.clonedeep@4.5.0 +-- lodash.restparam@3.6.1 +-- lodash.union@4.6.0 +-- lodash.uniq@4.5.0 +-- lodash.without@4.4.0 +-- mississippi@1.3.0 | +-- concat-stream@1.6.0 | | — typedarray@0.0.6
| +— duplexify@3.5.0
| | +— end-of-stream@1.0.0
| | | -- once@1.3.3 | | — stream-shift@1.0.0
| +— end-of-stream@1.1.0
| | -- once@1.3.3 | +-- flush-write-stream@1.0.2 | +-- from2@2.3.0 | +-- parallel-transform@1.1.0 | | — cyclist@0.2.2
| +— pump@1.0.2
| +— pumpify@1.3.5
| +— stream-each@1.2.0
| | -- stream-shift@1.0.0 | — through2@2.0.3
| -- xtend@4.0.1 +-- mkdirp@0.5.1 | — minimist@0.0.8
+— move-concurrently@1.0.1
| +— copy-concurrently@1.0.3
| -- run-queue@1.0.3 +-- node-gyp@3.5.0 | +-- minimatch@3.0.3 | | — brace-expansion@1.1.6
| | +— balanced-match@0.4.2
| | -- concat-map@0.0.1 | — nopt@3.0.6
+— nopt@4.0.1
| -- osenv@0.1.4 | +-- os-homedir@1.0.2 | — os-tmpdir@1.0.2
+— normalize-git-url@3.0.2
+— normalize-package-data@2.3.6
| -- is-builtin-module@1.0.0 | — builtin-modules@1.1.1
+— npm-cache-filename@1.0.2
+— npm-install-checks@3.0.0
+— npm-package-arg@4.2.1
+— npm-registry-client@7.4.6
| -- concat-stream@1.6.0 | — typedarray@0.0.6
+— npm-user-validate@0.1.5
+— npmlog@4.0.2
| +— are-we-there-yet@1.1.2
| | -- delegates@1.0.0 | +-- console-control-strings@1.1.0 | +-- gauge@2.7.2 | | +-- object-assign@4.1.0 | | +-- signal-exit@3.0.2 | | +-- string-width@1.0.2 | | | +-- code-point-at@1.1.0 | | | — is-fullwidth-code-point@1.0.0
| | | -- number-is-nan@1.0.1 | | +-- supports-color@0.2.0 | | — wide-align@1.1.0
| -- set-blocking@2.0.0 +-- once@1.4.0 +-- opener@1.4.3 +-- osenv@0.1.4 | +-- os-homedir@1.0.2 | — os-tmpdir@1.0.2
+— path-is-inside@1.0.2
+— read@1.0.7
| -- mute-stream@0.0.5 +-- read-cmd-shim@1.0.1 +-- read-installed@4.0.3 | — util-extend@1.0.3
+— read-package-json@2.0.5
| -- json-parse-helpfulerror@1.0.3 | — jju@1.3.0
+— read-package-tree@5.1.5
+— readable-stream@2.2.3
| +— buffer-shims@1.0.0
| +— core-util-is@1.0.2
| +— isarray@1.0.0
| +— process-nextick-args@1.0.7
| +— string_decoder@0.10.31
| -- util-deprecate@1.0.2 +-- readdir-scoped-modules@1.0.2 +-- realize-package-specifier@3.0.3 +-- request@2.81.0 | +-- aws-sign2@0.6.0 | +-- aws4@1.6.0 | +-- caseless@0.12.0 | +-- combined-stream@1.0.5 | | — delayed-stream@1.0.0
| +— extend@3.0.0
| +— forever-agent@0.6.1
| +— form-data@2.1.2
| | -- asynckit@0.4.0 | +-- har-validator@4.2.1 | | +-- ajv@4.11.4 | | | +-- co@4.6.0 | | | — json-stable-stringify@1.0.1
| | | -- jsonify@0.0.0 | | — har-schema@1.0.5
| +— hawk@3.1.3
| | +— boom@2.10.1
| | +— cryptiles@2.0.5
| | +— hoek@2.16.3
| | -- sntp@1.0.9 | +-- http-signature@1.1.1 | | +-- assert-plus@0.2.0 | | +-- jsprim@1.3.1 | | | +-- extsprintf@1.0.2 | | | +-- json-schema@0.2.3 | | | — verror@1.3.6
| | -- sshpk@1.11.0 | | +-- asn1@0.2.3 | | +-- assert-plus@1.0.0 | | +-- bcrypt-pbkdf@1.0.1 | | +-- dashdash@1.14.1 | | +-- ecc-jsbn@0.1.1 | | +-- getpass@0.1.6 | | +-- jodid25519@1.0.2 | | +-- jsbn@0.1.1 | | — tweetnacl@0.14.5
| +— is-typedarray@1.0.0
| +— isstream@0.1.2
| +— json-stringify-safe@5.0.1
| +— mime-types@2.1.14
| | -- mime-db@1.26.0 | +-- oauth-sign@0.8.2 | +-- performance-now@0.2.0 | +-- qs@6.4.0 | +-- safe-buffer@5.0.1 | +-- stringstream@0.0.5 | +-- tough-cookie@2.3.2 | | — punycode@1.4.1
| -- tunnel-agent@0.6.0 +-- retry@0.10.1 +-- rimraf@2.6.1 +-- semver@5.3.0 +-- sha@2.0.1 +-- slide@1.1.6 +-- sorted-object@2.0.1 +-- sorted-union-stream@2.1.3 | +-- from2@1.3.0 | | — readable-stream@1.1.14
| | +— core-util-is@1.0.2
| | +— isarray@0.0.1
| | -- string_decoder@0.10.31 | — stream-iterate@1.1.1
+— strip-ansi@3.0.1
+— tar@2.2.1
| -- block-stream@0.0.8 +-- text-table@0.2.0 +-- uid-number@0.0.6 +-- umask@1.1.0 +-- unique-filename@1.1.0 | — unique-slug@2.0.0
+— unpipe@1.0.0
+— update-notifier@2.1.0
| +— boxen@1.0.0
| | +— ansi-align@1.1.0
| | | -- string-width@1.0.2 | | | +-- code-point-at@1.1.0 | | | — is-fullwidth-code-point@1.0.0
| | | -- number-is-nan@1.0.1 | | +-- camelcase@4.0.0 | | +-- cli-boxes@1.0.0 | | +-- string-width@2.0.0 | | | — is-fullwidth-code-point@2.0.0
| | +— term-size@0.1.1
| | | -- execa@0.4.0 | | | +-- cross-spawn-async@2.2.5 | | | | — lru-cache@4.0.2
| | | | +— pseudomap@1.0.2
| | | | -- yallist@2.0.0 | | | +-- is-stream@1.1.0 | | | +-- npm-run-path@1.0.0 | | | +-- object-assign@4.1.1 | | | +-- path-key@1.0.0 | | | — strip-eof@1.0.0
| | -- widest-line@1.0.0 | | — string-width@1.0.2
| | +— code-point-at@1.1.0
| | -- is-fullwidth-code-point@1.0.0 | | — number-is-nan@1.0.1
| +— chalk@1.1.3
| | +— ansi-styles@2.2.1
| | +— escape-string-regexp@1.0.5
| | +— has-ansi@2.0.0
| | -- supports-color@2.0.0 | +-- configstore@3.0.0 | | +-- dot-prop@4.1.1 | | | — is-obj@1.0.1
| | -- unique-string@1.0.0 | | — crypto-random-string@1.0.0
| +— is-npm@1.0.0
| +— latest-version@3.0.0
| | -- package-json@3.1.0 | | +-- got@6.7.1 | | | +-- create-error-class@3.0.2 | | | | — capture-stack-trace@1.0.0
| | | +— duplexer3@0.1.4
| | | +— get-stream@3.0.0
| | | +— is-redirect@1.0.0
| | | +— is-retry-allowed@1.1.0
| | | +— is-stream@1.1.0
| | | +— lowercase-keys@1.0.0
| | | +— safe-buffer@5.0.1
| | | +— timed-out@4.0.1
| | | +— unzip-response@2.0.1
| | | -- url-parse-lax@1.0.0 | | | — prepend-http@1.0.4
| | +— registry-auth-token@3.1.0
| | | -- rc@1.1.7 | | | +-- deep-extend@0.4.1 | | | +-- minimist@1.2.0 | | | — strip-json-comments@2.0.1
| | -- registry-url@3.1.0 | | — rc@1.1.7
| | +— deep-extend@0.4.1
| | +— minimist@1.2.0
| | -- strip-json-comments@2.0.1 | +-- lazy-req@2.0.0 | +-- semver-diff@2.1.0 | — xdg-basedir@3.0.0
+— uuid@3.0.1
+— validate-npm-package-license@3.0.1
| +— spdx-correct@1.0.2
| | -- spdx-license-ids@1.2.0 | — spdx-expression-parse@1.0.2
| +— spdx-exceptions@1.0.4
| -- spdx-license-ids@1.2.0 +-- validate-npm-package-name@3.0.0 | — builtins@1.0.3
+— which@1.2.12
| -- isexe@1.1.2 +-- wrappy@1.0.2 — write-file-atomic@1.3.1

later install bootstrap, try below
$ npm install -g bootstrap@4.0.0-alpha.6

C:Users******AppDataRoamingnpm
-- bootstrap@4.0.0-alpha.6 +-- jquery@3.2.1 — tether@1.4.0

@jitendragupta2

while publishing my package was having package.json… so why it is not downloaded when i am installing my package

@ctoxyz

New to node… setup EC2 > AMAZON linux.. Node setup.. tried all kinds of versions..

no matter what i do, errors are obtained during install..

tried npm init… tried diff versions of all parts… still I can’t get a successful install & test code always fails.

Errors below. Please advise

npm install pdfkit
npm WARN saveError ENOENT: no such file or directory, open ‘/home/ec2-user/package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘/home/ec2-user/package.json’
npm WARN ec2-user No description
npm WARN ec2-user No repository field.
npm WARN ec2-user No README data
npm WARN ec2-user No license field.
npm WARN ec2-user Invalid dependency: png-js undefined

No matter what I install or how, i get these:

npm WARN saveError ENOENT: no such file or directory, open ‘/home/ec2-user/package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘/home/ec2-user/package.json’

@mihai-ciupina

You have to cd into location where package.json is; like assets in phoenix 1.3.x

@abdulmanan123

Angular 2 project not run forever show these errors:
npm ERR! path /package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open ‘/package.json’
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and 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/2017-05-30T12_02_40_976Z-debug.log
error: Forever detected script exited with code: 254
error: Script restart attempt #1
npm ERR! path /package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open ‘/package.json’
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

@jimmymixer

OS: Mac Sierra 10.12.5
Node v8.0.0.0
NPM v5.0.0

I’m having the same problem as well. I can’t seem to resolve this. I’ve tried both with and without sudo. I do have other programs installed in my computer. Don’t know if that has something to do with it. I have all of the Python Stack and Ruby Stack installed. Now trying to get all the MEAN Stack components installed.

Below is what I’m getting back. Any help would be greatly appreciated. When it talks about dependencies, I have no idea what that is.. Sorry for my poor knowledge.

TERMINAL:
Jaes-MacBook-Pro:bower_install jaepark75$ sudo npm install jquery
Password:
npm WARN saveError ENOENT: no such file or directory, open ‘/Users/jaepark75/package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘/Users/jaepark75/package.json’
npm WARN jaepark75 No description
npm WARN jaepark75 No repository field.
npm WARN jaepark75 No README data
npm WARN jaepark75 No license field.
npm WARN jaepark75 Invalid dependency: balanced-match undefined
npm WARN jaepark75 Invalid dependency: block-stream undefined
npm WARN jaepark75 Invalid dependency: brace-expansion undefined
npm WARN jaepark75 Invalid dependency: concat-map undefined
npm WARN jaepark75 Invalid dependency: fs.realpath undefined
npm WARN jaepark75 Invalid dependency: fstream undefined
npm WARN jaepark75 Invalid dependency: glob undefined
npm WARN jaepark75 Invalid dependency: graceful-fs undefined
npm WARN jaepark75 Invalid dependency: hammerjs undefined
npm WARN jaepark75 Invalid dependency: inflight undefined
npm WARN jaepark75 Invalid dependency: inherits undefined
npm WARN jaepark75 Invalid dependency: materialize-css undefined
npm WARN jaepark75 Invalid dependency: minimatch undefined
npm WARN jaepark75 Invalid dependency: minimist undefined
npm WARN jaepark75 Invalid dependency: mkdirp undefined
npm WARN jaepark75 Invalid dependency: node-archiver undefined
npm WARN jaepark75 Invalid dependency: once undefined
npm WARN jaepark75 Invalid dependency: path-is-absolute undefined
npm WARN jaepark75 Invalid dependency: rimraf undefined
npm WARN jaepark75 Invalid dependency: tar undefined
npm WARN jaepark75 Invalid dependency: wrappy undefined

updated 1 package in 4.539s

@Lisa-V-Sau

Hi,

I’ve got the same problem here and tried to run the following commands above to fix this. «Clean Cache» & «re-install». Unfortunately it didn’t fix it for me. Seems to have spawned another issue.

/Users/Karbon62/.npm/_logs/2017-06-05T14_42_36_153Z-debug.log

@Lisa-V-Sau

Before running the commands to fix this, my console was giving me this error:

file:///Users/Karbon62/.npm/_logs/2017-06-05T12_47_17_209Z-debug.log

@tylo6

OS: Mac Sierra 10.12.5
Node v8.0.0.0
NPM v5.0.2

i’ve the same probelm than jimmymixer whitout sucess.
If any have a idea to dig… Thank

TERMINAL:
_MacBook-Air-de-happy:~ happy$ npm install airsonos -g
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated static-favicon@1.0.2: use serve-favicon module
npm WARN deprecated react-tools@0.13.3: react-tools is deprecated. For more information, visit https://fb.me/react-tools-deprecated
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/airsonos -> /usr/local/lib/node_modules/airsonos/bin/index.js

  • airsonos@0.2.6_

then i installed latest «minimatch», «serve-favicon» and «react»
then

TERMINAL:
_MacBook-Air-de-happy:~ happy$ airsonos
Searching for Sonos devices on network…

/usr/local/lib/node_modules/airsonos/node_modules/bluebird/js/main/promise.js:680
throw e;
^
Error: Internal Server Error
at maybeWrapAsError (/usr/local/lib/node_modules/airsonos/node_modules/bluebird/js/main/util.js:70:12)
at /usr/local/lib/node_modules/airsonos/node_modules/bluebird/js/main/promise_resolver.js:41:50
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/logicalDevice.js:112:20
at done (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:126:15)
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:32:16
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/logicalDevice.js:106:22
at done (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:126:15)
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:32:16
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:251:17
at done (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:126:15)
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:32:16
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:248:21
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:572:34
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/events/volumeListener.js:24:14
at Listener. (/usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/events/listener.js:123:9)
at Request.self.callback (/usr/local/lib/node_modules/airsonos/node_modules/request/request.js:129:22)_

@travisgillespie

  • Create a package.json file and store it in the folder where you will install the npm package. Keep it simple for now. This npm video helped me. Also read Using a package.json for additional information. The following example satisfies the minimum requirements:
    {
    «name»: «demo-app»,
    «version»: «1.0.0»
    }

  • Open Terminal: as @mihai-ciupina pointed out… cd to the location where you want to store the package locally. If you type ls you should see the package.json file you just created.

  • Type: npm install <package_name>. The video above discusses variations you can type.

  • I’m not sure why, but my folder also created a package-lock.json file. I will have to do some more reading on this.

@mocombeg

Im trying to install gulp and I keep having thises issues:
Ive tried many remedies including: npm install npm@latest and still no progress.

C:Usershome>npm install npm@latest -g
C:UsershomeAppDataRoamingnpmnpm -> C:UsershomeAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js

  • npm@5.0.3
    updated 1 package in 24.356s

C:UsersM-Corp>npm install gulp
npm WARN saveError ENOENT: no such file or directory, open ‘C:Usershomepackage.json’
npm WARN enoent ENOENT: no such file or directory, open ‘C:Usershomepackage.json’
npm WARN home No description
npm WARN home No repository field.
npm WARN home No README data
npm WARN home No license field.

  • gulp@3.9.1
    updated 1 package in 2.495s

C:Usershome>

@avriLee

u just need to create package.json file in the needing directory, and enter npm init. It’s ok, and i tried successfully. Hope for u…

@LabAviator

Did anyone find a solution to this yet? I highly doubt that they haven’t fixed this bug yet.

@michael-ecb

Simply remove node_modules then run again ‘npm install’

@chethankumaril

when i run
$ npm install express, i got the following error.

rank@rank-ThinkCentre-M73:~$ npm install express
npm ERR! Linux 3.16.0-57-generic
npm ERR! argv «/home/rank/.nvm/versions/node/v5.0.0/bin/node» «/home/rank/.nvm/versions/node/v5.0.0/bin/npm» «install» «express»
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect

npm ERR! Error: connect ECONNREFUSED 127.0.0.1:8080
npm ERR! at Object.exports._errnoException (util.js:860:11)
npm ERR! at exports._exceptionWithHostPort (util.js:883:20)
npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
npm ERR! { [Error: connect ECONNREFUSED 127.0.0.1:8080]
npm ERR! code: ‘ECONNREFUSED’,
npm ERR! errno: ‘ECONNREFUSED’,
npm ERR! syscall: ‘connect’,
npm ERR! address: ‘127.0.0.1’,
npm ERR! port: 8080 }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! ‘proxy’ config is set properly. See: ‘npm help config’

npm ERR! Please include the following file with any support request:
npm ERR! /home/rank/npm-debug.log
rank@rank-ThinkCentre-M73:~$

@debug-js
debug-js

locked and limited conversation to collaborators

Sep 5, 2017

@Qix-

debug is not a repository to post your generic NPM-related problems; it’s a specific package that has nothing to do with most of the comments here.

Locking due to chatter. If you’re having lots of problems with NPM, might I suggest StackOverflow (please search first before asking a question). Alternatively, check out @mooyoul’s answer.

In this tutorial, we will help you to resolve the Error: ENOENT: no such file or directory, open
'student.json'
issue.

Node.js Tutorial :

  1. Install Node.js on Windows

  2. Node.js Chalk Color Example
  3. Node.js — Read command line arguments
  4. Node.js Read Write File Example
  5. Node.js Error: ENOENT: no such file or directory

Q: What is fs module in Nodejs?
Ans:

Node.js provides an inbuilt component called FS (File System). The Node. js file system module enables
us to interact with our computer’s file system.

Error: ENOENT: no such file or directory

Error: ENOENT: no such file or directory, open 'student.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.writeStudentData (D:nodejsfile-examplestudent-service-impl.js:24:21)
    at Object.handler (D:nodejsfile-examplestudent-app.js:10:17)
    at D:nodejsfile-examplenode_modulesyargsbuildindex.cjs:1:8891
    at j (D:nodejsfile-examplenode_modulesyargsbuildindex.cjs:1:4956)
    at M.handleValidationAndGetResult (D:nodejsfile-examplenode_modulesyargsbuildindex.cjs:1:8860)
    at M.applyMiddlewareAndGetResult (D:nodejsfile-examplenode_modulesyargsbuildindex.cjs:1:9502)
    at M.runCommand (D:nodejsfile-examplenode_modulesyargsbuildindex.cjs:1:7231)
    at Xt.[runYargsParserAndExecuteCommands] (D:nodejsfile-examplenode_modulesyargsbuildindex.cjs:1:57762) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',

Follow below steps to resolve Error: ENOENT: no such file or directory, open 'student.json'
issue.

  1. This problem occurs when a file does not exist; therefore, check to see if the file exists first.
  2. The suitable approach is to use fs.openSync, it
    returns the file descriptor.
  3. If the file does not exist, the w flag ensures that it is created, and if it does, it
    is overwritten
    with a new file, overriding its content.
  4. If users don’t need the file descriptor, users can close the file by wrapping the call in a
    fs.closeSync() call.
//check if file exist
if (!fs.existsSync('student.json')) {
    //create new file if not exist
    fs.closeSync(fs.openSync('student.json', 'w'));
}

Recommendation for Top Popular Post :

Nodejs Error: ENOENT: no such file or directory

This tutorial guides you on how to fix Nodejs Error: ENOENT: no such file or directory while running your node project or any application which contains Nodejs component.

Nodejs Error: ENOENT: no such file or directory

When I tried to download guacamole-client whose frontend is developed using Nodejs, and I tried to setup installing guacamole natively on Windows machine.

After downloading the code, I was trying to build guacamole-client which includes Nodejs frontend component by running “mvn package” command as shown below. But it resulted with error “Error: ENOENT: no such file or directory, open ‘C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontenddistnpm-dependencies.txt’

> mvn package
---
---
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputdirectivesguacKey.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputdirectivesguacTextInput.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputstylestextInput.css" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputtextInputModule.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptouchdirectivesguacTouchDrag.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptouchdirectivesguacTouchPinch.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptouchtouchModule.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcindex.html" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcrelocateParameters.js" (no NPM package)
[INFO] [webpack-cli] Error: ENOENT: no such file or directory, open 'C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontenddistnpm-dependencies.txt'
[INFO]     at Object.openSync (fs.js:476:3)
[INFO]     at Object.writeFileSync (fs.js:1467:35)
----
[INFO]     at AsyncSeriesHook.lazyCompileHook (C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontendnode_modulestapablelibHook.js:154:20)
[INFO]     at C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontendnode_moduleswebpacklibCompilation.js:1414:32 {
[INFO]   errno: -4058,
[INFO]   syscall: 'open',
[INFO]   code: 'ENOENT',
[INFO]   path: 'C:\Users\Documents\Work\guacamole-client-master\guacamole\src\main\frontend\dist\npm-dependencies.txt'
[INFO] }
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 2
[INFO] npm ERR! @ build: `webpack --progress`
[INFO] npm ERR! Exit status 2
[INFO] npm ERR!
[INFO] npm ERR! Failed at the @ build script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     C:UsersAppDataRoamingnpm-cache_logs21-07-28T14_42_52_884Z-debug.log

The above command “mvn package” is supposed to invoke maven to automatically build and package all the components, producing a single .war file. And while building frontend Nodejs component, it was looking for a file called “npm-depedencies.txt” but that file is missing.

Solution

As you can see from the above error, that it is expecting file called “npm-dependencies.txt” to be there in specific path. But it does not exist.

code: 'ENOENT',

path: 'C:\Users\Documents\Work\guacamole-client-master\guacamole\src\main\frontend\dist\npm-dependencies.txt'

ENOENT means Error NO ENTry (or Error NO ENTity) or simply you can say that there is NO such directory ENTry.

Therefore, you either need to create the expected file in the specific path i.e., under dist directory or else reconfigure your application so that it will point to the correct directory path for the required file.

After fixing, try building your application again. The Nodejs Error: ENOENT: no such file or directory should have gone away now.

Hope it helped 🙂

Also see:

  • Call ngOnInit() again from another function – Angular 9 ?
  • ngOnChanges get new value and previous value – Angular
  • Global Angular CLI version is greater than your local version
  • Upgrade Angular CLI to the latest version Angular 9 or 10 ?
  • How to use new static option in ViewChild Angular 9 ?
  • Project contents into angular components using ng-content
  • Call ngOnInit() again from another function – Angular 9 ?
  • ngAfterContentInit with Example – Angular
  • make npm install command to work behind proxy ?
  • Node Sass could not find a binding for your current environment
  • ngOnDestroy Example Angular
  • Angular Component : In which lifecycle hook you can check value of DOM element ?
  • @ContentChild TypeError: Cannot read property ‘nativeElement’ of undefined
  • Access ng-content with @ContentChild – Angular Component
  • How to select an element in a component template – Angular ?
  • Difference between @ViewChild and @ContentChild – Angular Example
  • Expected 0 type arguments, but got 1 : Angular
  • Angular – Access template reference variables from component class ?
  • Pass variable from parent to custom child component – Angular 9
  • Uninstall Nodejs completely from Mac OSX ?
  • EventEmitter parameter value undefined for listener
  • Typescript Error: Property does not exist on value of type
  • Remove http and https proxy settings of npm and git ?
  • How to change node version using nvm ?

References:

  • github nvm
  • nodejs docs


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.

You will encounter various kinds of errors while developing Node.js
applications, but most can be avoided or easily mitigated with the right coding
practices. However, most of the information to fix these problems are currently
scattered across various GitHub issues and forum posts which could lead to
spending more time than necessary when seeking solutions.

Therefore, we’ve compiled this list of 15 common Node.js errors along with one
or more strategies to follow to fix each one. While this is not a comprehensive
list of all the errors you can encounter when developing Node.js applications,
it should help you understand why some of these common errors occur and feasible
solutions to avoid future recurrence.

🔭 Want to centralize and monitor your Node.js error logs?

Head over to Logtail and start ingesting your logs in 5 minutes.

1. ECONNRESET

ECONNRESET is a common exception that occurs when the TCP connection to
another server is closed abruptly, usually before a response is received. It can
be emitted when you attempt a request through a TCP connection that has already
been closed or when the connection is closed before a response is received
(perhaps in case of a timeout). This exception will usually
look like the following depending on your version of Node.js:

Output

Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at Socket.socketOnEnd (node:_http_client:466:23)
    at Socket.emit (node:events:532:35)
    at endReadableNT (node:internal/streams/readable:1346:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET'
}

If this exception occurs when making a request to another server, you should
catch it and decide how to handle it. For example, you can retry the request
immediately, or queue it for later. You can also investigate your timeout
settings if you’d like to wait longer for the request to be
completed.

On the other hand, if it is caused by a client deliberately closing an
unfulfilled request to your server, then you don’t need to do anything except
end the connection (res.end()), and stop any operations performed in
generating a response. You can detect if a client socket was destroyed through
the following:

app.get("/", (req, res) => {
  // listen for the 'close' event on the request
  req.on("close", () => {
    console.log("closed connection");
  });

  console.log(res.socket.destroyed); // true if socket is closed
});

2. ENOTFOUND

The ENOTFOUND exception occurs in Node.js when a connection cannot be
established to some host due to a DNS error. This usually occurs due to an
incorrect host value, or when localhost is not mapped correctly to
127.0.0.1. It can also occur when a domain goes down or no longer exists.
Here’s an example of how the error often appears in the Node.js console:

Output

Error: getaddrinfo ENOTFOUND http://localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'http://localhost'
}

If you get this error in your Node.js application or while running a script, you
can try the following strategies to fix it:

Check the domain name

First, ensure that you didn’t make a typo while entering the domain name. You
can also use a tool like DNS Checker to confirm that
the domain is resolving successfully in your location or region.

Check the host value

If you’re using http.request() or https.request() methods from the standard
library, ensure that the host value in the options object contains only the
domain name or IP address of the server. It shouldn’t contain the protocol,
port, or request path (use the protocol, port, and path properties for
those values respectively).

// don't do this
const options = {
  host: 'http://example.com/path/to/resource',
};

// do this instead
const options = {
  host: 'example.com',
  path: '/path/to/resource',
};

http.request(options, (res) => {});

Check your localhost mapping

If you’re trying to connect to localhost, and the ENOTFOUND error is thrown,
it may mean that the localhost is missing in your hosts file. On Linux and
macOS, ensure that your /etc/hosts file contains the following entry:

You may need to flush your DNS cache afterward:

sudo killall -HUP mDNSResponder # macOS

On Linux, clearing the DNS cache depends on the distribution and caching service
in use. Therefore, do investigate the appropriate command to run on your system.

3. ETIMEDOUT

The ETIMEDOUT error is thrown by the Node.js runtime when a connection or HTTP
request is not closed properly after some time. You might encounter this error
from time to time if you configured a timeout on your
outgoing HTTP requests. The general solution to this issue is to catch the error
and repeat the request, preferably using an
exponential backoff
strategy so that a waiting period is added between subsequent retries until the
request eventually succeeds, or the maximum amount of retries is reached. If you
encounter this error frequently, try to investigate your request timeout
settings and choose a more appropriate value for the endpoint
if possible.

4. ECONNREFUSED

The ECONNREFUSED error is produced when a request is made to an endpoint but a
connection could not be established because the specified address wasn’t
reachable. This is usually caused by an inactive target service. For example,
the error below resulted from attempting to connect to http://localhost:8000
when no program is listening at that endpoint.

Error: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
Emitted 'error' event on ClientRequest instance at:
    at Socket.socketErrorListener (node:_http_client:442:9)
    at Socket.emit (node:events:526:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000
}

The fix for this problem is to ensure that the target service is active and
accepting connections at the specified endpoint.

5. ERRADDRINUSE

This error is commonly encountered when starting or restarting a web server. It
indicates that the server is attempting to listen for connections at a port that
is already occupied by some other application.

Error: listen EADDRINUSE: address already in use :::3001
    at Server.setupListenHandle [as _listen2] (node:net:1330:16)
    at listenInCluster (node:net:1378:12)
    at Server.listen (node:net:1465:7)
    at Function.listen (/home/ayo/dev/demo/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/home/ayo/dev/demo/main.js:16:18)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 3001
}

The easiest fix for this error would be to configure your application to listen
on a different port (preferably by updating an environmental variable). However,
if you need that specific port that is in use, you can find out the process ID
of the application using it through the command below:

Output

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    2902  ayo   19u  IPv6 781904      0t0  TCP *:3001 (LISTEN)

Afterward, kill the process by passing the PID value to the kill command:

After running the command above, the application will be forcefully closed
freeing up the desired port for your intended use.

6. EADDRNOTAVAIL

This error is similar to EADDRINUSE because it results from trying to run a
Node.js server at a specific port. It usually indicates a configuration issue
with your IP address, such as when you try to bind your server to a static IP:

const express = require('express');
const app = express();

const server = app.listen(3000, '192.168.0.101', function () {
  console.log('server listening at port 3000......');
});

Output

Error: listen EADDRNOTAVAIL: address not available 192.168.0.101:3000
    at Server.setupListenHandle [as _listen2] (node:net:1313:21)
    at listenInCluster (node:net:1378:12)
    at doListen (node:net:1516:7)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRNOTAVAIL',
  errno: -99,
  syscall: 'listen',
  address: '192.168.0.101',
  port: 3000
}

To resolve this issue, ensure that you have the right IP address (it may
sometimes change), or you can bind to any or all IPs by using 0.0.0.0 as shown
below:

var server = app.listen(3000, '0.0.0.0', function () {
  console.log('server listening at port 3000......');
});

7. ECONNABORTED

The ECONNABORTED exception is thrown when an active network connection is
aborted by the server before reading from the request body or writing to the
response body has completed. The example below demonstrates how this problem can
occur in a Node.js program:

const express = require('express');
const app = express();
const path = require('path');

app.get('/', function (req, res, next) {
  res.sendFile(path.join(__dirname, 'new.txt'), null, (err) => {
    console.log(err);
  });
  res.end();
});

const server = app.listen(3000, () => {
  console.log('server listening at port 3001......');
});

Output

Error: Request aborted
    at onaborted (/home/ayo/dev/demo/node_modules/express/lib/response.js:1030:15)
    at Immediate._onImmediate (/home/ayo/dev/demo/node_modules/express/lib/response.js:1072:9)
    at processImmediate (node:internal/timers:466:21) {
  code: 'ECONNABORTED'
}

The problem here is that res.end() was called prematurely before
res.sendFile() has had a chance to complete due to the asynchronous nature of
the method. The solution here is to move res.end() into sendFile()‘s
callback function:

app.get('/', function (req, res, next) {
  res.sendFile(path.join(__dirname, 'new.txt'), null, (err) => {
    console.log(err);
    res.end();
  });
});

8. EHOSTUNREACH

An EHOSTUNREACH exception indicates that a TCP connection failed because the
underlying protocol software found no route to the network or host. It can also
be triggered when traffic is blocked by a firewall or in response to information
received by intermediate gateways or switching nodes. If you encounter this
error, you may need to check your operating system’s routing tables or firewall
setup to fix the problem.

9. EAI_AGAIN

Node.js throws an EAI_AGAIN error when a temporary failure in domain name
resolution occurs. A DNS lookup timeout that usually indicates a problem with
your network connection or your proxy settings. You can get this error when
trying to install an npm package:

Output

npm ERR! code EAI_AGAIN
npm ERR! syscall getaddrinfo
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/nestjs failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

If you’ve determined that your internet connection is working correctly, then
you should investigate your DNS resolver settings (/etc/resolv.conf) or your
/etc/hosts file to ensure it is set up correctly.

10. ENOENT

This error is a straightforward one. It means «Error No Entity» and is raised
when a specified path (file or directory) does not exist in the filesystem. It
is most commonly encountered when performing an operation with the fs module
or running a script that expects a specific directory structure.

fs.open('non-existent-file.txt', (err, fd) => {
  if (err) {
    console.log(err);
  }
});

Output

[Error: ENOENT: no such file or directory, open 'non-existent-file.txt'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'non-existent-file.txt'
}

To fix this error, you either need to create the expected directory structure or
change the path so that the script looks in the correct directory.

11. EISDIR

If you encounter this error, the operation that raised it expected a file
argument but was provided with a directory.

// config is actually a directory
fs.readFile('config', (err, data) => {
  if (err) throw err;
  console.log(data);
});

Output

[Error: EISDIR: illegal operation on a directory, read] {
  errno: -21,
  code: 'EISDIR',
  syscall: 'read'
}

Fixing this error involves correcting the provided path so that it leads to a
file instead.

12. ENOTDIR

This error is the inverse of EISDIR. It means a file argument was supplied
where a directory was expected. To avoid this error, ensure that the provided
path leads to a directory and not a file.

fs.opendir('/etc/passwd', (err, _dir) => {
  if (err) throw err;
});

Output

[Error: ENOTDIR: not a directory, opendir '/etc/passwd'] {
  errno: -20,
  code: 'ENOTDIR',
  syscall: 'opendir',
  path: '/etc/passwd'
}

13. EACCES

The EACCES error is often encountered when trying to access a file in a way
that is forbidden by its access permissions. You may also encounter this error
when you’re trying to install a global NPM package (depending on how you
installed Node.js and npm), or when you try to run a server on a port lower
than 1024.

fs.readFile('/etc/sudoers', (err, data) => {
  if (err) throw err;
  console.log(data);
});

Output

[Error: EACCES: permission denied, open '/etc/sudoers'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/etc/sudoers'
}

Essentially, this error indicates that the user executing the script does not
have the required permission to access a resource. A quick fix is to prefix the
script execution command with sudo so that it is executed as root, but this is
a bad idea
for security reasons.

The correct fix for this error is to give the user executing the script the
required permissions to access the resource through the chown command on Linux
in the case of a file or directory.

sudo chown -R $(whoami) /path/to/directory

If you encounter an EACCES error when trying to listen on a port lower than
1024, you can use a higher port and set up port forwarding through iptables.
The following command forwards HTTP traffic going to port 80 to port 8080
(assuming your application is listening on port 8080):

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

If you encounter EACCES errors when trying to install a global npm package,
it usually means that you installed the Node.js and npm versions found in your
system’s repositories. The recommended course of action is to uninstall those
versions and reinstall them through a Node environment manager like
NVM or Volta.

14. EEXIST

The EEXIST error is another filesystem error that is encountered whenever a
file or directory exists, but the attempted operation requires it not to exist.
For example, you will see this error when you attempt to create a directory that
already exists as shown below:

const fs = require('fs');

fs.mkdirSync('temp', (err) => {
  if (err) throw err;
});

Output

Error: EEXIST: file already exists, mkdir 'temp'
    at Object.mkdirSync (node:fs:1349:3)
    at Object.<anonymous> (/home/ayo/dev/demo/main.js:3:4)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -17,
  syscall: 'mkdir',
  code: 'EEXIST',
  path: 'temp'
}

The solution here is to check if the path exists through fs.existsSync()
before attempting to create it:

const fs = require('fs');

if (!fs.existsSync('temp')) {
  fs.mkdirSync('temp', (err) => {
    if (err) throw err;
  });
}

15. EPERM

The EPERM error may be encountered in various scenarios, usually when
installing an npm package. It indicates that the operation being carried out
could not be completed due to permission issues. This error often indicates that
a write was attempted to a file that is in a read-only state although you may
sometimes encounter an EACCES error instead.

Here are some possible fixes you can try if you run into this problem:

  1. Close all instances of your editor before rerunning the command (maybe some
    files were locked by the editor).
  2. Clean the npm cache with npm cache clean --force.
  3. Close or disable your Anti-virus software if have one.
  4. If you have a development server running, stop it before executing the
    installation command once again.
  5. Use the --force option as in npm install --force.
  6. Remove your node_modules folder with rm -rf node_modules and install them
    once again with npm install.

Conclusion

In this article, we covered 15 of the most common Node.js errors you are likely
to encounter when developing applications or utilizing Node.js-based tools, and
we discussed possible solutions to each one. This by no means an exhaustive list
so ensure to check out the
Node.js errors documentation or the
errno(3) man page for a
more comprehensive listing.

Thanks for reading, and happy coding!

Check Uptime, Ping, Ports, SSL and more.

Get Slack, SMS and phone incident alerts.

Easy on-call duty scheduling.

Create free status page on your domain.

Got an article suggestion?
Let us know

Share on Twitter

Share on Facebook

Share via e-mail

Next article

How to Configure Nginx as a Reverse Proxy for Node.js Applications

Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

У меня есть веб-приложение Nodejs, которое в настоящее время выполняется на сервере успешно. Теперь я пытаюсь настроить локальную копию на моем сервере разработки.

В настоящее время у меня установлены Nodejs, NPM и Mongo, как и у меня на рабочем сервере, однако при попытке запустить node server

Что может быть причиной этой проблемы?

[email protected]:~/node/nodeapp$ node app.js
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/home/embah/node/nodeapp/config/c
onfig.json'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Object.<anonymous> (/home/embah/node/nodeapp/config/config.js:4:28)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/embah/node/glorby/app.js:13:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
[email protected]:~/node/nodeapp$

4b9b3361

Ответ 1

Ваше приложение ожидает найти файл в /home/embah/node/nodeapp/config/config.json, но этот файл не существует (что означает ENOENT). Таким образом, вам нужно либо создать ожидаемую структуру каталогов, либо настроить приложение таким образом, чтобы оно выглядело в правильном каталоге для config.json.

Ответ 2

Пройдя через множество ссылок и потоков и разочаровавшись снова и снова, я пошел к основам и буму! это помогло. Я просто сделал:

npm install

Я не знаю, но это может кому-то помочь :)

Ответ 3

У меня также была эта проблема, потому что у меня было открыто другое окно консоли, в котором выполнялось приложение, и я пытался повторно запустить запуск пряжи в другом окне консоли.

Выполнение первой пряжи помешало написанию второй. Так что я просто убил первый процесс, и он работал

Ответ 4

В моем случае

import { Object } from '../config/env';

дал мне ошибку.

Я решил это с помощью изменения адреса следующим образом:

import { Object } from './../config/env';

Ответ 5

Ответ @olleh сработал, потому что npm install создаст каталог node_modules в текущем пути, где он выполняется. Таким образом, при использовании системного модуля файлового сервера, когда вы объявляете

const fs = require('fs')

это найти файлы из каталога верхнего уровня папки node_modules.

Ответ 6

92% дополнительных сценариев обработки ресурсов-webpack-plugin × 「wdm」: Ошибка: ENOENT: нет такого файла или каталога, откройте…. ==> если кто-то сталкивался с такой ошибкой, вы должны сделать следующее: 1) вы должны проверить Если путь к файлу в файле angular.json указан правильно.

 "scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.js"
        ],

2) вы должны нажать crtl + c и снова запустить проект.

Ответ 7

Это случилось со мной. Я удалил некоторые CSS файлы по ошибке, а затем скопировал обратно. Эта ошибка появилась в то время. Поэтому я перезагружаю все свои докеры и другие серверы, и затем он уходит, Возможно, это поможет кому-то :)

Понравилась статья? Поделить с друзьями:
  • Error english cover
  • Error endl was not declared in this scope
  • Error end1 was not declared in this scope
  • Error end of file expected line
  • Error end of centdir 64 signature not where expected prepended bytes