使用node_modules/.bin/webpack时无法读取未定义(mix.initialize())的属性 [英] Can't read property of undefined (mix.initialize() )when use node_modules/.bin/webpack

查看:40
本文介绍了使用node_modules/.bin/webpack时无法读取未定义(mix.initialize())的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 node_modules/.bin/webpack 进行编译,但出现此错误:

I'm trying to compile with node_modules/.bin/webpack and I get this error:

Mix.initialize();       
   ^       
TypeError: Cannot read property 'initialize' of undefined      
at Object.<anonymous> (/home/vagrant/Code/stream/webpack.config.js:9:4)            
at Module._compile (module.js:570:32)      
at Object.Module._extensions..js (module.js:579:10)      
at Module.load (module.js:487:32)  
at tryModuleLoad (module.js:446:12)      
at Function.Module._load (module.js:438:3)       
at Module.require (module.js:497:17)      
at require (internal/module.js:20:19)      
at requireConfig 
(/home/vagrant/Code/stream/node_modules/webpack/bin/convert-argv.js:97:18)     
at /home/vagrant/Code/stream/node_modules/webpack/bin/convert-argv.js:104:17    

webpack.mix.js :

let mix = require('laravel-mix').mix;       
mix.js('resources/assets/js/app.js', 'public/js')      
.sass('resources/assets/sass/app.scss', 'public/css');    

webpack.config.js :

var path = require('path');       
var webpack = require('webpack');      
var Mix = require('laravel-mix').config;    
var plugins = require('laravel-mix').plugins;    
Mix.initialize();

我正在关注此视频:然后在03:29崩溃,我真的很感谢您的帮助.

And crash at 03:29, i really appreciate any help.

推荐答案

好吧,我终于做到了.

在视频中,他一开始删除了一些package.json软件包.(包括laravel-mix),然后安装laravel-mix 0.3版本.

In video he remove some package of package.json at the beginning. (laravel-mix included) and after this he install laravel-mix 0.3 version.

因此,当我创建laravel项目时,我不会删除laravel-mix(版本为"0. *".如果我这样做并运行npm,则运行dev总是很好.

So when i create the laravel project i don't remove laravel-mix (the version is "0.*". If i do that and i run npm run dev always is good.

我不明白为什么他要先删除软件包并安装它,然后再做

I can't understand why he remove package and install it before, and do

cp -r node_modules/laravel-mix/setup/** ./

希望对某人有用.

这篇关于使用node_modules/.bin/webpack时无法读取未定义(mix.initialize())的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆