How to resolve Nodejs: Error: ENOENT: no such file or directory

I have a Nodejs web application that is currently running on the server successfully. Now I'm trying to set up a local copy on my development server.

Currently, I have Nodejs, NPM and Mongo installed, as I have on a production server, however, when I try to start the node server

What could be causing this problem?

embah@devsertwo:~/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
embah@devsertwo:~/node/nodeapp$
+20
source share
7 answers

/home/embah/node/nodeapp/config/config.json, ( ENOENT). , , , config.json.

+24

, ! . :

npm install

, - :)

+5

, , , .

. ,

+2

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

.

:

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

0

@olleh , npm install node_modules , . , ,

const fs = require('fs')

node_modules.

0

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 .

0

It happened to me. I deleted some CSS files by mistake and then copied back. This error appeared at that time. So I reboot all my dockers and other servers, and then it leaves, Maybe this will help someone :)

-one
source

Source: https://habr.com/ru/post/1016360/


All Articles