运行时参数1 scss中的NPM错误:npm run watch

时间:2018-04-13 03:12:26

标签: laravel npm webpack mix laravel-mix

这是它向我显示的错误,我将 webpack.mix.js scss 的参数1放入 scss <列表< / strong>我会在应用中使用:

MarshalResult(data='{"users": [{"email": "mr@bean.com", "fullname": "Mr. Bean"}, {"email": "james@bond.com", "fullname": "James Bond"}]}', errors={})

这是webpack.mix.js:

> @ watch /media/ricardo/FILES/projects/Laravel/costurita-etl
> npm run development -- --watch


> @ development /media/ricardo/FILES/projects/Laravel/costurita-etl
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

assert.js:49
   throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: mix.sass() is missing required parameter 1: src
    at Function.preprocessor (/media/ricardo/FILES/projects/Laravel/costurita-etl/node_modules/laravel-mix/src/Verify.js:32:9)
    at Sass.preprocess (/media/ricardo/FILES/projects/Laravel/costurita-etl/node_modules/laravel-mix/src/components/Preprocessor.js:134:16)
    at Sass.register (/media/ricardo/FILES/projects/Laravel/costurita-etl/node_modules/laravel-mix/src/components/Sass.js:12:21)
    at Api.mix.(anonymous function).args [as sass] (/media/ricardo/FILES/projects/Laravel/costurita-etl/node_modules/laravel-mix/src/components/ComponentFactory.js:98:53)
    at Object.<anonymous> (/media/ricardo/FILES/projects/Laravel/costurita-etl/webpack.mix.js:24:2)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
[The usual npm errors...]

2 个答案:

答案 0 :(得分:0)

这是因为.sasstranspiler命令,而不是combiner命令,您将其视为.js,而不是app.scss。< / p>

相反,@import应该是所有依赖项的唯一真实来源,您可以使用// app.scss @import '~bootstrap/scss/src/bootstrap-grid'; @import '~bootstrap/scss/src/bootstrap-reboot'; @import '~bootstrap/scss/src/bootstrap'; // the rest of your code 将这些依赖项纳入您的sass文件中;观察:

~

node_modules是对.scss目录的引用,因此您可以省略路径的硬编码。您也不需要在此处声明app.scss扩展程序。

最后,您只需将路径传递给.sass作为.sass('resources/assets/sass/app.scss') 命令的字符串参数:

str = "This is an example sentence, it is for demonstration only"

答案 1 :(得分:0)

即使我遇到了同样的错误...下面的 webpack.mix.js 代码帮助我解决了这个问题。

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