找不到模块:错误:使用MongoDB时无法解析'dns' [英] Module not found: Error: Can't resolve 'dns' when using MongoDB

查看:238
本文介绍了找不到模块:错误:使用MongoDB时无法解析'dns'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Reactjs,Nodejs和MongoDB的新手。我目前正在尝试更改Mediums雪花工具以将用户分数存储在数据库中。我通过npm安装了yarn,mongodb和mongodb-core。这是一个单页面的Web应用程序,我认为这会给我带来麻烦。我添加

I'm new to Reactjs, Nodejs and MongoDB. I'm currently trying to change Mediums snowflake tool to store users scores in a database. I have installed yarn, mongodb and mongodb-core through npm. It is a single page web application which is what I think is causing me trouble. I add

var MongoClient = require('mongodb');

SnowflakeApp.js 并遇到以下情况错误:

To SnowflakeApp.js and encounter the following error:


找不到模块:错误:无法解析
'中的'dns'/ home / mlAHO174 /雪花/ node_modules / mongodb-core / lib'

Module not found: Error: Can't resolve 'dns' in '/home/mlAHO174/snowflake/node_modules/mongodb-core/lib'

我试过谷歌搜索这个错误并发现它可能是一系列的事情。我不确定是不是因为React是前端而我正在尝试改变后端或因为mongoDB安装不正确。我是新手,所以非常感谢你的帮助!

I've tried googling this error and have discovered it could be a range of things. I'm not sure if it is because React is front end and I'm trying to alter back end or because mongoDB is installed incorrectly. I'm new to this so would be grateful for help!

推荐答案

欢迎来到堆栈溢出。

您需要了解和学习一些Web应用程序的基础知识。它有前端,后端和它们之间的层以及后端和数据库之间的层。前端包括 react.js angular.js 或浏览器上的任何其他内容。后端用于从前端接收请求,提供API到前端并从其他API或数据库请求数据。数据库包括 sql no-sql

You need to understand and learn few basics of web-applications. There's frontend, backend and a layer between them and a layer between backend and database. Frontend includes react.js, angular.js or anything else that is on browser. Backend is used to take request from frontend, providing API's to frontend and ask for data from other API's or database. Database includes sql, no-sql.

如果是NPM模块,您面临的错误 mongodb-core.js 。要么未正确安装,要么使用与您的节点版本无法比较的错误版本的模块,或错误的NPM版本或使用未安装的其他NPM模块的模块进行安装。

The error you are facing if of a NPM module mongodb-core.js. Either it's not installed properly, or installed using wrong version of module which is not comparable with your node version, or wrong version of NPM, or module using another NPM module which is not installed.

您的案例中的问题是 mongodb-core 使用模块 dns 尚未安装。尝试使用 npm i dns 安装 dns 。或者再次删除并安装 mongodb-core

The issue in your case is mongodb-core uses a module dns which is not been installed. Try to install dns with npm i dns. or remove and install mongodb-core again.

这篇关于找不到模块:错误:使用MongoDB时无法解析'dns'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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