javascript - 无法缩小捆绑包。错误:来自 Terser 的 static/js/main.68c81611.chunk.js
问题描述
我得到这个错误,当我运行
npm run deploy
在我的反应项目上。到目前为止,我还没有添加任何外部依赖项,除了 gh-pages 模块。
package.json 文件:
{
"name": "data-validation",
"version": "0.1.0",
"private": true,
"homepage": "https://kristoffertolboll2.github.io/react-js-data-validation/",
"dependencies": {
"gh-pages": "^2.0.1",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
这是我收到的错误消息
Failed to minify the bundle. Error: static/js/main.68c81611.chunk.js from Terser
//long stacktrace
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! data-validation@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the data-validation@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Kristoffer\AppData\Roaming\npm-cache\_logs\2019-02-02T22_38_15_532Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! data-validation@0.1.0 predeploy: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the data-validation@0.1.0 predeploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Kristoffer\AppData\Roaming\npm-cache\_logs\2019-02-02T22_38_15_570Z-debug.log
我尝试删除 node_modules 文件夹并执行
npm install
但出现同样的问题,它似乎可能是一个旧的依赖项?
解决方案
对于yarn用户:将以下字段添加到package.json,然后重新运行
"resolutions": {
"terser": "3.14.1"
}
If npm
run npm iterser@3.14
推荐阅读
- c# - 如何将 Azure 托管标识与 Azure.Storage.Blobs.BlobServiceClient 一起使用?
- angular - Angular Service 不是全局单例
- php - 如何在 PHP 中使用相同的循环获取 $_POST 和 $_FILES 请求
- android - 运行子进程cordova 时出错。sh 无法识别
- testing - 在嵌入式设备上创建文件系统损坏
- ecmascript-6 - 使用地图和箭头功能将 2 个列表合二为一
- android - 我想在 kotlin 中使用 setter 来设置文档快照的值
- rest - 多对多资源映射restful api设计
- scheme - 方案::R5RS。尝试做绝对值程序
- sql - 关于如何分离 UpdateTarget 和 Filter