admin管理员组文章数量:1278793
An issue with next.js
Module not found: Can't resolve 'dns' in '/Users/Austin/node_modules/pg/lib'
Could not find files for /index in .next/build-manifest.json
ModuleNotFoundError: Module not found: Error: Can't resolve 'dns' in '/Users/Austin/node_modules/pg/lib'
I'm having a hard time understanding this error message. I'm using next.js and trying to create different webpages. I'll start the program, running npm run dev, and it will give me this at first:
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ ready ] piled successfully - ready on http://localhost:3000
[ wait ] piling ...
[ ready ] piled successfully - ready on http://localhost:3000
and following that give me this error. What does this error mean? I've found different answers online and none of them have worked so far.
An issue with next.js
Module not found: Can't resolve 'dns' in '/Users/Austin/node_modules/pg/lib'
Could not find files for /index in .next/build-manifest.json
ModuleNotFoundError: Module not found: Error: Can't resolve 'dns' in '/Users/Austin/node_modules/pg/lib'
I'm having a hard time understanding this error message. I'm using next.js and trying to create different webpages. I'll start the program, running npm run dev, and it will give me this at first:
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ ready ] piled successfully - ready on http://localhost:3000
[ wait ] piling ...
[ ready ] piled successfully - ready on http://localhost:3000
and following that give me this error. What does this error mean? I've found different answers online and none of them have worked so far.
Share Improve this question edited Aug 18, 2021 at 20:36 brc-dd 13k3 gold badges59 silver badges86 bronze badges asked Dec 4, 2019 at 16:30 user5491053user5491053 1- I guess showing some code would be helpful, as your index page, next.js config. – Evgeny Timoshenko Commented Dec 5, 2019 at 10:15
1 Answer
Reset to default 14I've run into the same issue. The message is not super helpful but it means you are trying to run node.js/server side code on the client. For example, my problem was importing my db connection file in one of my front end page ponents. On the client app, I import db.js
that is trying to connect to a db, but that db connection requires the dns
module which is native to node.js. The browser can't execute and then throws the error. This is an easy trap to fall into because the line between frontend and backend code is blurry in Next.js apps.
本文标签: javascriptModule not found Can39t resolve 39dns39 in 39UsersAustinnodemodulespglib39Stack Overflow
版权声明:本文标题:javascript - Module not found: Can't resolve 'dns' in 'UsersAustinnode_modulespglib' - S 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741212624a2359427.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论