Node-sass is not recognized by command line

后端 未结 5 1840
情深已故
情深已故 2021-02-07 14:16

I\'m trying to set up node-sass, following the instructions on CSS-Tricks. Node and npm are installed correctly, and the node-sass installation worked too. When I go to run

相关标签:
5条回答
  • 2021-02-07 14:26

    You need to install it globally

    npm install -g node-sass
    

    Or add it in package.json

    "devDependencies": {
        "node-sass": "4.5.0"
    },
    "scripts" : {
        "node-sass": "node-sass --output-style compressed -o dist/css src/scss"
    }
    

    And then do
    1. npm i, which in this case would be similar to npm install --save-dev node-sass
    2. npm run node-sass

    Reference: npm scripts, npm-run-scripts

    0 讨论(0)
  • 2021-02-07 14:29

    npm commands check "node_package" folder and try to run things there. You can try

    npx run scss 
    

    to install scss and then run it, even if it is not installed before.

    0 讨论(0)
  • 2021-02-07 14:29

    The below solves the problem

    yarn global add node-sass-chokidar
    
    0 讨论(0)
  • 2021-02-07 14:30

    This is a simple problem don't worry too much. Just go to package.json file and add this code

    "devDependencies": {
        "node-sass": "4.9.2"
    },
    "scripts" : {
        "node-sass": "node-sass --output-style compressed -o dist/css/ scss --recursive"
    }
    

    and just save the file.

    And run this command,

    **npm run node-sass**
    

    That's all

    0 讨论(0)
  • 2021-02-07 14:39

    node-sass v4.13+

    1. Install node-sass in your project locally
    cd <root path of your project>
    yarn add -D node-sass
    // or
    npm install -D node-sass
    
    1. Add a script to your package.json
    "scripts" : {
    ...
      "compile:sass": "node-sass --recursive --watch <sass directory> --output <css directory>",
    ...
    }
    
    1. Run the script from the command line
    yarn compile:sass
    // or
    npm run compile:sass
    
    0 讨论(0)
提交回复
热议问题