nam run *在更新webpack.mix.ks后无法正常工作

时间:2017-08-29 16:20:52

标签: laravel laravel-5 npm less

我正在开发一个laravel项目并尝试添加更少的样式表。

但是,当我从这里更改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.
 |
 */

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

为:

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/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');
mix.less('resources/assets/less/main.less', 'public/css');

我的npm停止工作。当我尝试在这些更改后执行 npm run dev 时,我收到以下错误:

> @ dev /Applications/MAMP/htdocs/***.dev
> npm run development


> @ development /Applications/MAMP/htdocs/***.dev
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

Additional dependencies must be installed. This will only take a moment.
/bin/sh: yarn: command not found
child_process.js:515
    throw err;
    ^

Error: Command failed: yarn add less-loader less --save
/bin/sh: yarn: command not found

    at checkExecSyncError (child_process.js:472:13)
    at execSync (child_process.js:512:13)
    at installDependencies (/Applications/MAMP/htdocs/***.dev/node_modules/laravel-mix/src/Verify.js:127:5)
    at Function.dependency (/Applications/MAMP/htdocs/***.dev/node_modules/laravel-mix/src/Verify.js:103:13)
    at Api.less (/Applications/MAMP/htdocs/***.dev/node_modules/laravel-mix/src/Api.js:113:16)
    at Object.<anonymous> (/Applications/MAMP/htdocs/***.dev/webpack.mix.js:16:5)
    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)

npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "development"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
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 '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! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     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! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Applications/MAMP/htdocs/***.dev/npm-debug.log

npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Applications/MAMP/htdocs/***.dev/npm-debug.log

我不知道问题是什么,并且已经尝试重新安装npm和laravel mix。还清除了npm缓存..

1 个答案:

答案 0 :(得分:0)

尝试运行以下内容:

npm install -g yarn

然后再试一次