尝试构建 next.js 示例应用程序时从 Terser 获取 TypeError
Getting TypeError from Terser when trying to build next.js sample app
当我按照 https://github.com/zeit/next.js 上的设置部分设置新的 next.js 应用程序时,我在尝试构建时遇到错误。
符合以下内容:
错误:(客户端)来自 Terser 的 static/chunks/commons.91235769179a31c41c74.js
类型错误:无法读取未定义的 属性 'minify'...
我有几个 next.js 站点 运行 正在生产中,没有任何问题。以前没有经历过。
我在 GitHub 上设置了一个示例存储库:
https://github.com/wegeberg/next-terser-error
下面是我的package.json。
{
"name": "next-terser-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"author": "",
"license": "ISC",
"dependencies": {
"next": "^7.0.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
}
}
这是我能制作的最简单的示例。我希望 "npm run build" 到 运行 没有错误。但是,无论 运行 在 Mac 或 Debian 上使用代码,我都会遇到上述错误。
修复在这里:https://github.com/webpack-contrib/terser-webpack-plugin/issues/66#issue-406001469
我删除了我的 node_modules
文件夹,将其添加到 package.json
:
"resolutions": {
"terser": "3.14.1"
}
重新安装,再次尝试构建,成功了。
当我按照 https://github.com/zeit/next.js 上的设置部分设置新的 next.js 应用程序时,我在尝试构建时遇到错误。
符合以下内容: 错误:(客户端)来自 Terser 的 static/chunks/commons.91235769179a31c41c74.js 类型错误:无法读取未定义的 属性 'minify'...
我有几个 next.js 站点 运行 正在生产中,没有任何问题。以前没有经历过。
我在 GitHub 上设置了一个示例存储库: https://github.com/wegeberg/next-terser-error
下面是我的package.json。
{
"name": "next-terser-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"author": "",
"license": "ISC",
"dependencies": {
"next": "^7.0.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
}
}
这是我能制作的最简单的示例。我希望 "npm run build" 到 运行 没有错误。但是,无论 运行 在 Mac 或 Debian 上使用代码,我都会遇到上述错误。
修复在这里:https://github.com/webpack-contrib/terser-webpack-plugin/issues/66#issue-406001469
我删除了我的 node_modules
文件夹,将其添加到 package.json
:
"resolutions": {
"terser": "3.14.1"
}
重新安装,再次尝试构建,成功了。