Laravel Mix和JS - npm运行dev - 95%发出错误:EIO:i / o错误,关闭

时间:2018-01-02 18:15:36

标签: node.js laravel npm laravel-5.5 laravel-mix

每当我尝试使用本地Laravel 5.5项目中包含的app.js编译运行Laravel Mix npm run dev时,我会收到以下错误:

95% emittingError: EIO: i/o error, close
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-01-02T17_38_00_013Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-01-02T17_38_00_037Z-debug.log

这里是日志文件的内容:

0 info it worked if it ends with ok
1 verbose cli [ '/home/vagrant/.nvm/versions/node/v9.3.0/bin/node',
1 verbose cli   '/home/vagrant/.nvm/versions/node/v9.3.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'development' ]
2 info using npm@5.6.0
3 info using node@v9.3.0
4 verbose run-script [ 'predevelopment', 'development', 'postdevelopment' ]
5 info lifecycle aqualis2@~predevelopment: aqualis2@
6 info lifecycle aqualis2@~development: aqualis2@
7 verbose lifecycle aqualis2@~development: unsafe-perm in lifecycle true
8 verbose lifecycle aqualis2@~development: PATH: /home/vagrant/.nvm/versions/node/v9.3.0/lib/node_modules/npm/bin/node-gyp-bin:/home/vagrant/aqualis2/node_modules/.bin:/home/vagrant/.nvm/versions/node/v9.3.0/lib/node_modules/npm/bin/node-gyp-bin:/home/vagrant/aqualis2/node_modules/.bin:/home/vagrant/.nvm/versions/node/v9.3.0/bin:/home/vagrant/.composer/vendor/bin:/home/vagrant/bin:/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle aqualis2@~development: CWD: /home/vagrant/aqualis2
10 silly lifecycle aqualis2@~development: Args: [ '-c',
10 silly lifecycle   'node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
11 silly lifecycle aqualis2@~development: Returned: code: 1  signal: null
12 info lifecycle aqualis2@~development: Failed to exec development script
13 verbose stack Error: aqualis2@ development: `node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/home/vagrant/.nvm/versions/node/v9.3.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at EventEmitter.emit (events.js:159:13)
13 verbose stack     at ChildProcess.<anonymous> (/home/vagrant/.nvm/versions/node/v9.3.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:159:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid aqualis2@
15 verbose cwd /home/vagrant/aqualis2
16 verbose Linux 4.4.0-51-generic
17 verbose argv "/home/vagrant/.nvm/versions/node/v9.3.0/bin/node" "/home/vagrant/.nvm/versions/node/v9.3.0/bin/npm" "run" "development"
18 verbose node v9.3.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error aqualis2@ development: `node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
22 error Exit status 1
23 error Failed at the aqualis2@ development script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

这是我的webpack.min.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.
 |
 */
// on configure webpack
mix.webpackConfig({
    module:  {
        loaders: [
            {
                test:   require.resolve('pace-progress'),
                loader: 'imports?define=>false',
            },
        ],
    },
    node:    {
        fs: 'empty',
    },
    resolve: {
        alias: {
            'handlebars': 'handlebars/dist/handlebars.js',
        },
    },
});

// on copie les images non ciblées dans les scripts ou feuilles de style
mix.copy('resources/assets/*', 'public');
mix.copy('resources/assets/images/*', 'public/images');

// on compile/minifie les scripts et on isole les vendors
mix.js('resources/assets/js/app.js', 'public/js')
    .extract([
        'lodash',
        'jquery',
        'admin-lte',
        'lodash',
        'jquery',
        'admin-lte',
        'pace-progress',
        'jquery-slimscroll',
        'fastclick',
        'bootstrap-datepicker',
        'bootstrap-datepicker/dist/locales/bootstrap-datepicker.fr.min',
        'bootstrap-timepicker',
        'bootstrap-colorpicker',
        'icheck',
        'select2',
        'daterangepicker',
        'handlebars',
        'jspdf',
        'html2pdf.js',
        'datatables.net',
        'datatables.net-bs',
        'datatables.net-responsive',
        'datatables.net-responsive-bs',
        'bootbox',
        'moment',
        'moment/locale/fr',
        'highcharts/highstock',
        'highcharts/modules/exporting',
        'highcharts/modules/export-data',
        'highcharts/modules/no-data-to-display',
        'pusher-js',
        'laravel-echo',
        'vue'
    ]);

// on compile/minifie la feuille de style pour bootstrap
mix.sass('resources/assets/sass/bootstrap.scss', 'public/css/bs.css');

// on compile/minifie la feuille de style pour le thème admin-lte
mix.less('resources/assets/less/adminlte.less', 'public/css')
    .options({
        processCssUrls: false,
    });

// on compile/minifie notre feuille de style perso
mix.sass('resources/assets/sass/app.scss', 'public/css');

// on active les sourcemaps
mix.sourceMaps();

// on versionne nos images, scripts et feuilles de style
mix.version();

if (!mix.inProduction()) {
    mix.browserSync(process.env.APP_URL);
}

我的app.js内容:

require("./bootstrap");
require("./common");

我知道这是由于JS,因为如果我注释掉.extract([...])和所有bootstrap.js内容它会编译,但是如果我有任何引用它的库它会中断(例如,如果引导程序的内容它会中断.js仅为window._ = require('lodash');

这真的很奇怪,因为当我使用全新的Laravel安装时,它首先可以工作但是在对webpack.config.js进行任何更改之后它会中断并回滚它并没有帮助:一旦它&#39我已经破了,我不能再工作了。

我在Windows 10机器上使用Homestead,节点和npm版本(我尝试使用nvm来解决问题,但不幸的是它不起作用):

vagrant@homestead:~/laravel_test$ node -v
v9.3.0

vagrant@homestead:~/laravel_test$ npm -v
5.6.0

有关进展情况的任何线索?

2 个答案:

答案 0 :(得分:0)

对于任何有同样问题的人,经过2周的调查,我终于找到了原因:在流浪的家园上启用了NFS!我只是删除了该选项,现在可以使用了。

答案 1 :(得分:0)

在带有流浪汉的Windows上,唯一适用于我的解决方案是从任务管理器中手动结束“用于Windows的NFS服务器”过程,然后执行vagrant reload