如何解决Nodejs:错误:ENOENT:没有这样的文件或目录 [英] How to resolve Nodejs: Error: ENOENT: no such file or directory

查看:46
本文介绍了如何解决Nodejs:错误:ENOENT:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Nodejs Web 应用程序当前在服务器上成功运行.现在我正在尝试在我的开发服务器上设置一个本地副本.

I have a Nodejs web app currently running on a server successfully. Now I'm trying to setup a local copy on my Development server.

我目前安装了 Nodejs、NPM 和 Mongo,就像我在生产服务器上安装的一样,但是当我尝试启动节点服务器时出现以下错误

I currently have Nodejs, NPM and Mongo Installed just like what I have in production server however the error below occurs when I try to start node server

是什么导致了这个问题?

Whats could be causing this issue?

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$

推荐答案

您的应用程序希望在 /home/embah/node/nodeapp/config/config.json 找到一个文件,但该文件不存在(这就是 ENOENT 的意思).因此,您要么需要创建预期的目录结构,要么配置您的应用程序,使其在 config.json 的正确目录中查找.

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.

这篇关于如何解决Nodejs:错误:ENOENT:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆