【问题标题】:How to compile sass without gulp and laravel-elixir [ FIX ]如何在没有 gulp 和 laravel-elixir 的情况下编译 sass [修复]
【发布时间】:2020-05-05 19:43:46
【问题描述】:

如果您收到类似this 的错误:

那么你来对地方了:)

【问题讨论】:

    标签: php node.js laravel npm sass


    【解决方案1】:

    首先,您必须从项目中删除 node_modules 文件夹。 为此,请键入以下命令:

    请注意,在删除 package.json 之前复制模块名称 :)

    1. rm -rf 节点模块
    2. rm -rf package-lock.json
    3. rm -rf package.json
    4. npm 缓存清理

    现在你需要一个新的 package.json 来做这个你需要这个命令:

    • npm 初始化

    回车直到命令行返回。

    现在您需要安装 Node-Sass 来执行此操作,输入以下命令:

    • npm install node-sass

    如果权限有问题,用 sudo 试试,像这样:

    • sudo npm install node-sass

    安装Node-sass后,你需要编写Node-sass命令,进入package.json文件,你会看到如下内容:

    {
      "name": "blog",
      "version": "1.0.0",
      "description": "Bla Bla Bla Bla ...",
      "main": "gulpfile.js",
      "directories": {
        "test": "tests"
      },
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "bootstrap": "^4.4.1",
        "jquery": "^3.4.1",
        "node-sass": "^4.13.1"
      }
    }
    

    在脚本部分的 test 命令下添加一个 scss 命令,如下所示:

    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1",
      "scss": "node-sass resources/assets/sass -o public/css"
    }
    

    你可以使用 --watch 选项,像这样:

    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1",
      "scss": "node-sass --watch resources/assets/sass -o public/css"
    }
    

    这意味着如果有更改则监视目录或文件,换句话说,每次您点击CTRL + SCMD + S时,它都会编译所有.scss文件。

    最后,运行脚本:

    • npm 运行 scss

    非常感谢Zviad Sichinava

    详细了解node-sass

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多