运行时出现此错误

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! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! [email protected] predeploy: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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


但是出现相同的问题,看来它可能是旧的依赖关系?

最佳答案

当前的terser(3.16)版本似乎存在问题,到目前为止,您应该在package.json中将版本设置为3.14.1,如下所示:"terser": "3.14.1",

关于javascript - 无法缩小捆绑包。错误:来自Terser的static/js/main.68c81611.chunk.js,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54498223/

10-09 22:52