今天再重新配置老项目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. 数据结构与算法 --- js描述队列

    js描述队列 队列的特性是只能在队尾插入元素,在队首删除元素,先进先出: 队列被用在很多地方,比如提交操作系统执行的一系列进程,打印任务池,模拟现实中的排队: //队列类 function Queue ...

  2. Nginx(二) 常用配置

    全局配置段 # 允许运行nginx服务器的用户和用户组 user www-data; # 并发连接数处理(进程数量),跟cpu核数保存一致: worker_processes auto; # 存放 n ...

  3. alert弹出窗口,点击确认后关闭页面

    alert("点击确认后,关闭页面"); window.opener=null;window.top.open('','_self','');window.close(this);

  4. Linux 误删catlina.out导致磁盘空间爆满,无法查询到大文件解决办法

    大概是前俩天吧,发现公司的网站不定时的出现接口调不通的情况,便让手下小弟去服务器上查看一下,小弟告我磁盘空间满了,于是我让他处理一下.结果没想到他直接把 catlina.out 给干掉了.后果可想而知 ...

  5. shell正则表达式提取数字

    grep 提取数字 grep -Po "\d+\.\d+"

  6. Webpack 一,打包JS

    创建入口文件 app.js // es6 module 规范 import sum_d from './sum.js' import {sum_e} from './sum.js' // commco ...

  7. 机器学习总结-sklearn参数解释

    本文转自:lytforgood 机器学习总结-sklearn参数解释 实验数据集选取: 1分类数据选取 load_iris 鸢尾花数据集 from sklearn.datasets import lo ...

  8. Codeforces_820

    A.直接模拟. #include<bits/stdc++.h> using namespace std; int c,v0,v1,a,l; int main() { ios::sync_w ...

  9. Navicat Premium 12(破解版免安装)

    获取安装包解压至任意位置 切勿更新!!! 切勿更新!!! 切勿更新!!! 扫下方二维码关注公众号回复:navicat12即可获取

  10. php 页面分页样式 示例

    <?php class SubPages { private $each_disNums; //每页显示的条目数 private $nums; //总条目数 private $current_p ...