今天再重新配置老项目node打包环境的时候遇到了一个问题。

在打包的时候报:

TypeError: Cannot read property 'compilation' of undefined 错误。

(这里需要强调一下,安装环境的使用一定要-save-dev或者是-save,否则欲哭无泪啊)

很明显,这是node一些包的版本对应不上的问题。。。

1、首先定位到uglifyjs-webpack-plugin中的index.js文件中,将项目中的该包升级或者降级到1.0.0版本

npm i uglifyjs-webpack-plugin@1.0.0 --save

2、然后定位到optimize-css-assets-webpack-plugin\node_modules\last-call-webpack-plugin\src\index.js文件报错

将项目中的该包(optimize-css-assets-webpack-plugin)升级或者降级到2.0.0版本

npm i optimize-css-assets-webpack-plugin@2 --save

3、这个时候报缺少"cssnano"包,直接安装上即可(到这一步就成功了)

4、最后附上丑化压缩配置

// CSS压缩丑化
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
// JavaScript压缩丑化
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
drop_debugger: true,
drop_console: true
}
},
sourceMap: true,
parallel: true
}),
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true,
map: {
inline: false
}
}
}),

站在巨人的肩膀上摘苹果:

原文:https://blog.csdn.net/u011169370/article/details/83346176

webpack打包进行丑化压缩遇到(TypeError Cannot read property 'compilation' of undefined)问题的更多相关文章

  1. TypeError: Cannot read property 'compilation' of undefined

    Vue build失败 TypeError: Cannot read property 'compilation' of undefined 1.   使用npm run build 失败 使用npm ...

  2. 使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法

    我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示 One CLI for webpack must be installed. These are rec ...

  3. 转载:TypeError: Cannot read property 'compilation' of undefined vue 打包运行npm run build 报错

    转载自:https://www.jianshu.com/p/3f8f60e01797 运行npm run build打包时,报错如下:   我的package.json如下: { ... " ...

  4. [one day one question] webpack 打包报错 Cannot assign to read only property 'exports' of object '#<Object>'

    问题描述: webpack 打包报错 Cannot assign to read only property 'exports' of object '#<Object>',这怎么破? 解 ...

  5. index.js:13 Uncaught TypeError: Cannot read property 'split' of undefined

    使用 webpack 编译 Vue 项目时出现报错: index.js:13 Uncaught TypeError: Cannot read property 'split' of undefined ...

  6. Vue使用Typescript开发编译时提示“ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'afterCompile' of undefined”的解决方法

    使用Typescript开发Vue,一切准备就绪.但npm start 时,提示“ ERROR in ./src/main.tsModule build failed: TypeError: Cann ...

  7. TypeError: Cannot read property 'tap' of undefined

    E:\vue-project\vue-element-admin-master>npm run build:prod vue-element-admin@3.8.1 build:prod E:\ ...

  8. vue.common.js?e881:433 TypeError: Cannot read property 'nodeName' of undefined

    我觉得吧,是这么个原因,就是响应式要找这个node改它的内容,没找着,就报错了. 用computed监控vuex的state属性,绑定到页面上,如果这个属性改了,因为响应式,那么就要更改页面,如果页面 ...

  9. Uncaught TypeError: Cannot read property 'msie' of undefined

    因为图方便,抄了别人写的一个jquerry插件,运行时“var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ...

随机推荐

  1. Xmind8 Pro 破解教程(序列号|破解文件)

    最近需要打开文件后缀名为.xmind的文件,所以下载了Xmind8 .打开以后想要导出,奈何普通版本只能导出.txt文本文档,所以只好动手pj.话不多说看下边.一.下载XMindCrack.jar文件 ...

  2. Shell常用脚本之用户操作

    批量创建10个系统帐号oldboy01-oldboy10并设置密码,密码为随机8位字符串 #!/bin/bash ..} do useradd $user -] | ` | passwd --stdi ...

  3. 理解Java虚拟机中的栈、堆、堆栈

    JAVA的JVM的内存可分为3个区:堆(heap).栈(stack)和方法区(method) 栈区: 每个线程包含一个栈区,栈中只保存方法中(不包括对象的成员变量)的基础数据类型和自定义对象的引用(不 ...

  4. Leetcode 题目整理-5 Valid Parentheses & Merge Two Sorted Lists

    20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', ...

  5. 多线程之CountDownLatch的用法及原理笔记

    前言-CountDownLatch是什么? CountDownLatch是具有synchronized机制的一个工具,目的是让一个或者多个线程等待,直到其他线程的一系列操作完成. CountDownL ...

  6. 聊聊SpringBoot | 第一章:快速搭建SpringBoot第一个应用

    快速搭建SpringBoot第一个应用 1.简介 本章仅介绍如何快速搭建第一个SpringBoot应用,细节内容下一章再做讲解,如果有需要,各位可以直接到Spring官网去了解. 从 Spring B ...

  7. 码云(gitee)配置ssh密钥

    创建公钥的目的: 使用SSH公钥可以让你在你的电脑和码云通讯的时候使用安全连接(git的remote要使用SSH地址) git中粘贴右击鼠标选择Paste 步骤: 打开终端(git)进入.ssh目录 ...

  8. 使用Qt自动注册Lav

    Qt播放视频使用QMediaPlayer要注册Lav解码器,如果手动去注册,每次去使用管理员运行命令或者生成.bat文件都比较麻烦. 解决方法步骤如下: 一:编写注册Lav解码器脚本,并取消控制台的显 ...

  9. The current test process

    样机测试 测试前: 工作内容: 1.需求分析.编写.评审: 项目开工会由项目负责人参加,参加会议时做好笔记,对项目的功能类似,功能模块,测试时间点有个大致的了解. 原始需求进行需求文档细化:按照模块进 ...

  10. Codeforces_814

    A.b序列从大到小填a序列中的0,在判断. #include<bits/stdc++.h> using namespace std; ],b[]; int main() { ios::sy ...