Node / npm:使用node-sass编译scss时未找到要导入的文件

时间:2016-03-22 16:46:43

标签: javascript node.js sass npm node-sass

我正在尝试使用sass中的node-sass使用package.json编译我的"node-sass": "node-sass --output-style compressed 'src/scss/styles.scss' 'dist/css/bundle.min.css'",

styles.scss

我的@import "bourbon"; @import "neat"; body {background: red;}

npm run node-sass

但是当我运行 "formatted": "Error: File to import not found or unreadable: bourbon\n Parent style sheet: /Users/deangibson/Desktop/personal_site/src/scss/styles.scss\n on line 1 of src/scss/styles.scss\n>> @import \"bourbon\";\n ^\n", "message": "File to import not found or unreadable: bourbon\nParent style sheet: /Users/deangibson/Desktop/personal_site/src/scss/styles.scss", "column": 1, "line": 1, "file": "/Users/deangibson/Desktop/personal_site/src/scss/styles.scss", "status": 1 } 时,我收到以下错误:

class Name: SWRevealViewControllerDelegate

override func viewDidLoad() {
  super.viewDidLoad()

   self.revealViewController().delegate = self

}

我的项目结构如下:

enter image description here

当涉及到依赖项时,节点是否应该只是自动检入node_modules?我不明白我在这里做错了什么......

1 个答案:

答案 0 :(得分:4)

是的,node会自动在require的JavaScript文件中查找您node_modules的内容。但是,您正在执行命令行应用程序node-sass,但它不会执行此操作。

您可以像这样提供--include-pathnode-sass命令行应用(可读性多行,需要在package.json中单行显示)

node-sass 
  --output-style compressed 
  --include-path node_modules/bourbon/app/assets/stylesheets/ 
  --include-path node_modules/bourbon-neat/app/assets/stylesheets/ 
  'src/scss/styles.scss' 
  'dist/css/bundle.min.css'

如果您撰写render JavaScript file that is executed with node,可以通过合并arrays exported by the bourbon modules when you require them来设置includePath