type
Post
status
Published
date
Mar 3, 2025
slug
webpack-next-build-error-uuid
summary
记录一下遇到的 Next10 老项目在build过程中遇到的问题
tags
前端
JavaScript
开发
category
技术分享
icon
password
记录一下遇到的 Next10 老项目在build过程中遇到的问题
💻 现象
Failed to compile.
./node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v35.js
Module parse failed: Unexpected token (19:18)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Build error occurred Error: > Build failed because of webpack errors

📝 原因
uuid使用的esmodule语法,在Next10进行服务端编译是只能编译 commonjs语法,需要把这个包手动转换成commonjs语法