肉饼博客

Talk is cheap. Show me the code.

0%

Next.js 搭配 AntD 问题总结

一、AntD

1.Warning: useLayoutEffect does nothing on the server

解决:AntD降级到4.15.6

2.Warning: findDOMNode is deprecated in StrictMode

解决:next.config.js中reactStrictMode设为false

二、Next.js

1.next js chunkloaderror loading chunk node_modules next_dist_client_dev_noop js failed

解决:删除.next文件夹

2.Next.js API routes (and pages) should support reading files

解决:配置使用import导入

3.如何使用pm2启动

解决:

1
2
3
4
5
6
"scripts": {
"dev": "next dev",
"build": "next build && PORT=4000 npm start",
"start": "next start",
"deploy": "pm2 start npm --name mlcNext --log-type=json --log-date-format 'YYYY-MM-DD HH:mm:ss' -- run build"
}