如何在不出现npm错误的情况下将sass编译为css

时间:2020-08-27 13:48:07

标签: css node.js npm sass

SASS 编译为 CSS 时,总是会出现此错误

An output directory must be specified when compiling a directory
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! natours@1.0.0 compile:sass: `node-sass scss/main.scss css/style.css`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the natours@1.0.0 compile:sass 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!     /home/haq/.npm/_logs/2020-08-27T13_30_14_538Z-debug.log

1 个答案:

答案 0 :(得分:2)

正确的语法是node-sass scss/main.scss -o css/styles.css

编辑:

node-sass要求您显式指定输出文件夹/文件,-o选项位于此处!

解释所有命令:

  • 您首先致电node-sass
  • 然后您指定scss文件(将其作为输入)
  • -o用于指定输出文件夹的选项
  • 然后输出文件夹/文件

如果您需要有关node-sass选项的更多信息,请转到他的npm页面,该文件有据可查:https://www.npmjs.com/package/node-sass