gpt4 book ai didi

javascript - npx webpack - 无法读取未定义的属性 'minify'

转载 作者:可可西里 更新时间:2023-11-01 02:21:19 26 4
gpt4 key购买 nike

我正在通过此链接关注 webpack 的基本教程:https://webpack.js.org/guides/getting-started/

当我运行 npx webpack 时,它失败并出现以下错误:

ERROR in main.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/Users/name/Documents/practice/webpack/webpack-demo/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
at module.exports (/Users/name/Documents/practice/webpack/webpack-demo/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
at handle (/Users/name/Documents/practice/webpack/webpack-demo/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/Users/name/Documents/practice/webpack/webpack-demo/node_modules/worker-farm/lib/child/index.js:51:3)
at process.emit (events.js:188:13)
at emit (internal/child_process.js:828:12)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
  • 节点版本:v11.6.0
  • npm 版本:6.5.0-next.0
  • webpack版本:4.29.0
  • webpack-cli 版本:3.2.1

文件夹结构

/dist
index.html
/node_modules
/src
index.js
package-lock.json
package.json

index.html

<!doctype html>
<html>
<head>
<title>Getting Started</title>
</head>
<body>
<script src="main.js"></script>
</body>
</html>

索引.js

import _ from 'lodash';

function component() {
let element = document.createElement('div');
element.innerHTML = _.join(['hello', 'webpack'], ' ');
return element;
}

document.body.appendChild(component());

package.json

{
"name": "webpack-demo",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1"
},
"dependencies": {
"lodash": "^4.17.11"
}
}

最佳答案

这是一个错误,您可以通过安装 terser v3.14 来修复它

只需运行:

npm i -D terser@3.14

来源:https://github.com/vuejs/vue-cli/issues/3407#issuecomment-459985313

关于javascript - npx webpack - 无法读取未定义的属性 'minify',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54499626/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com