vue.js - VueJS:为生产构建时出错
问题描述
我一直在尝试构建我以前构建得很好的代码的生产版本。现在,当我vue build
在 main.js 文件上运行时,它提供了以下内容:
\ Building for production...Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
\ Building for production...Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
\ Building for production...Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
(node:10708) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: CSS minification error: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's`. Maybe you are using old Browserslist or made typo in query.. File: css/app.75eb53b0.css
(node:10708) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我试图通过手动更新包和依赖于它的包、启动新项目、运行npm --depth 999
命令(深度 9999 导致内存堆错误)以及我能找到的所有其他内容来解决 Browserslist/caniuse-lite 错误做。我没有使用 VS(使用 VS 代码),但试图通过从我的 AppData 中删除 WebCompiler 信息来解决问题,但开始时没有 WebCompiler 文件夹。
我还尝试恢复到 css-loader 2.1.1,它解决了在处理此问题时出现的另一个问题,但它没有解决这个问题。
任何帮助将不胜感激,因为这会阻止任何更新发布到生产。
我已尝试在其他线程中修复有关 Browserslist 警告的问题。此外,这些线程没有提到以下错误:
(node:10708) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: CSS minification error: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's`. Maybe you are using old Browserslist or made typo in query.. File: css/app.75eb53b0.css
(node:10708) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
以下是我的项目的 package.json
{
"name": "coeus",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-brands-svg-icons": "^5.11.2",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fortawesome/vue-fontawesome": "^0.1.7",
"axios": "^0.19.0",
"bcrypt": "^3.0.6",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"bootstrap-vue": "^2.0.2",
"browserslist": "^4.7.0",
"caniuse-lite": "^1.0.30000997",
"cors": "^2.8.5",
"dns": "^0.2.2",
"express": "^4.17.1",
"express-fileupload": "^1.1.5",
"fast-csv": "^3.4.0",
"json-loader": "^0.5.7",
"jsonwebtoken": "^8.5.1",
"method-override": "^3.0.0",
"mongoose": "^5.7.1",
"morgan": "^1.9.1",
"nodemailer": "^6.3.0",
"npm": "^6.11.3",
"path": "^0.12.7",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuex": "^3.1.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"@vue/eslint-config-prettier": "^5.0.0",
"css-loader": "^2.1.1",
"style-loader": "^1.0.0",
"vue-template-compiler": "^2.6.10"
}
}
解决方案
我不确定这是为什么(我可能在文档中错过了它),但我发现我正在使用vue build
命令来构建生产版本。在查看了一些东西之后,我尝试了npm run build
,不仅没有收到 Browserslist 警告,而且也没有遇到缩小错误。谢谢大家的帮助!
推荐阅读
- python - 使用正确的 MIME 类型使用 Python 将文件上传到 S3(保持原始文件夹结构)
- hibernate - 数据库回调,如 PreUpdate、PreInsert with Spring data jpa 和 QueryDSL
- c++ - 如何使用作为参数传递的信息来构建在其他 CPP 文件中定义的字符串
- google-apps-script - Google Form onsubmit 获取用户电子邮件和全名
- r - 在 R 中提取栅格的最快方法(提高可重现代码的时间)
- r - 使用 R 进行网页抓取,如何使用“打印('NA')”就是缺乏
的?
- excel - SUMIF 与 listdown 标准 pt.2
- javascript - React Collapse - 我如何切换列表中的项目?
- properties - wix 在 PublishProduct 之前将 INSTALLLOCATION 传递给我的自定义对话框中的编辑控件
- lambda - 是否存在两个外延相等但具有不同范式的 lambda 项?