Laravel Mix npm运行开发错误

时间:2018-08-21 10:54:55

标签: laravel npm vue.js npm-install laravel-mix

我尝试使用npm run development,但出现跟随错误。

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function
   -> The entry point(s) of the compilation.
   Details:
    * configuration.entry['/js/app'] should be a string.
      -> The string is resolved to a module which is loaded upon startup.
    * configuration.entry['/js/app'] should not contain the item '.../resources/assets/sass/app.scss' twice.
    * configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    * configuration.entry should be an array:
      [non-empty string]
    * configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.

我的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.scripts([
    'public/assets/js/jquery-3.3.1.min.js',
    'public/assets/js/popper.min.js',
    'public/assets/js/bootstrap.min.js',
    'public/assets/js/moment.min.js',
    'public/assets/js/sweetalert.min.js',
    'public/assets/js/delete.handler.js',
    'public/assets/plugins/js-cookie/js.cookie.js',
    'public/vendor/jsvalidation/js/jsvalidation.js',
    'public/assets/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js',
    'public/assets/plugins/croppie/croppie.js'
], 'public/assets/js/vendor.js');

mix.styles([
    'public/assets/css/fontawesome-all.min.css',
    'public/assets/plugins/bootstrap-datepicker/bootstrap-datepicker.min.css',
    'public/assets/plugins/croppie/croppie.css',
], 'public/assets/css/vendor.css');

mix.sass('resources/assets/sass/app.scss', 'public/assets/css');

mix.copy('node_modules/toastr/build/toastr.min.js', 'public/vendor/toastr/toastr.min.js'); 

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

if (mix.inProduction()) {
    mix.version();
}

1 个答案:

答案 0 :(得分:0)

为什么不复制所有包(jQuery,Popper,Bootstrap,Moment),为什么不编译大部分资产呢?

npm i jquery
npm i bootstrap
npm i @fortawesome/fontawesome-free
npm i moment, etc.

然后在/resources/js/bootstrap.js中,您可以包括这些软件包...

try {
    window.Popper = require('popper.js').default;
    window.$ = window.jQuery = require('jquery');

然后运行...

npm run prod