我正在尝试在Laravel项目中使用Laravel Mix,并使用此配置进行设置:
Laravel Mix:^1.0
webpack.mix.js
let mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix
.js('resources/assets/admin/js/app.js', 'public/assets/admin');
正在运行npm run dev
我收到此错误:
$ npm run dev
> @ dev c:\Users\user\laravel
> npm run development
> @ development c:\Users\user\laravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress
--hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
undefined:3
}
^
SyntaxError: Unexpected token } in JSON at position 26
at Object.parse (native)
at babelrc (c:\Users\user\laravel\node_modules\l
aravel-mix\src\config.js:212:36)
at global.tap (c:\Users\user\laravel\node_module
s\laravel-mix\src\helpers.js:10:5)
at Object.babel (c:\Users\user\laravel\node_modu
les\laravel-mix\src\config.js:210:13)
at module.exports (c:\Users\user\laravel\node_mo
dules\laravel-mix\src\builder\webpack-rules.js:15:33)
at WebpackConfig.buildRules (c:\Users\user\laravel\node_modules\laravel-mix\src\builder\WebpackConfig.js:81:41)
at WebpackConfig.build (c:\Users\user\laravel\no
de_modules\laravel-mix\src\builder\WebpackConfig.js:25:14)
at Object.<anonymous> (c:\Users\user\laravel\nod
e_modules\laravel-mix\setup\webpack.config.js:26:38)
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 (c:\Users\user\laravel\node_mod
ules\webpack\bin\convert-argv.js:97:18)
我不确定这个错误。似乎错误是laravel-mix源代码,但是当我升级到1.6
时,我也遇到了同样的错误。
此外,我添加并删除了app.js
中的所有代码,但错误相同。
注意:
虽然适用于0.8
版本。