【问题标题】:Node-sass not compilingNode-sass 未编译
【发布时间】:2020-12-09 21:31:41
【问题描述】:

尝试使用 node-sass 从 scss 制作 css 文件。 我的 package.json:

 {
  "name": "hello-webpack",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "scss": "node-sass -watch scss -o css"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "sass": "^1.26.10",
    "sass-loader": "^9.0.3",
    "webpack": "^4.44.1",
    "webpack-cli": "^3.3.11"
  },
  "dependencies": {
    "node-sass": "^4.14.1"
  }
}

但是当我尝试 npm run scss 时,我看到了这个错误:

> node-sass -watch scss -o css

internal/validators.js:120
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:120:11)
    at Object.extname (path.js:1229:5)
    at getOptions (/Users/mac/Documents/Website/node_modules/node-sass/bin/node-sass:192:40)
    at Object.<anonymous> (/Users/mac/Documents/Website/node_modules/node-sass/bin/node-sass:376:15)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-webpack@1.0.0 scss: `node-sass -watch scss -o css`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the hello-webpack@1.0.0 scss 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!     /Users/mac/.npm/_logs/2020-08-20T14_02_52_371Z-debug.log

路径有什么问题?没错,我有目录 scss 和 css,并且两者都有一些文件。

【问题讨论】:

    标签: sass node-sass


    【解决方案1】:

    您正在使用带有全名的 watch 选项,需要 2 个破折号:

    node-sass scss --watch -o css
    

    否则使用 1 个破折号和简写 w 名称:

    node-sass scss -w -o css
    

    https://www.npmjs.com/package/node-sass#command-line-interface

    【讨论】:

      猜你喜欢
      • 2015-02-17
      • 1970-01-01
      • 2018-07-17
      • 2013-03-18
      • 1970-01-01
      • 2021-11-08
      • 2020-05-14
      • 2021-05-21
      • 2017-05-03
      相关资源
      最近更新 更多