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'
Run Code Online (Sandbox Code Playgroud)
我很难理解这个错误信息。我正在使用 next.js 并尝试创建不同的网页。我将启动该程序,运行 npm run dev,它首先会给我以下信息:
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
Run Code Online (Sandbox Code Playgroud)
然后给我这个错误。这个错误是什么意思?我在网上找到了不同的答案,但到目前为止都没有奏效。
我遇到了同样的问题。该消息不是很有帮助,但它意味着您正在尝试在客户端上运行 node.js/服务器端代码。例如,我的问题是在我的前端页面组件之一中导入我的数据库连接文件。在客户端应用程序上,我导入db.js了它试图连接到数据库,但该数据库连接需要dnsnode.js 原生的模块。浏览器无法执行,然后抛出错误。这是一个容易陷入的陷阱,因为在 Next.js 应用程序中,前端和后端代码之间的界限是模糊的。
| 归档时间: |
|
| 查看次数: |
1307 次 |
| 最近记录: |