0

我正在尝试开始使用eyeglass@1.2.1并遇到问题,尽管发现了眼镜模块,但@import它们却失败了。

这是使用node-sass编译单个文件的gulp任务(此时仅使用gulp包装,因为我不知道如何获得漂亮的眼镜调试输出) 。

gulp.task('sass', () => {
  const options = eyeglass({
    file: path.join('test', 'test.scss'),
    engines: {
      sass: nodeSass
    }
  });
  return nodeSass.render(options, (err, result) => console.log(err, result));
});

有时候是这样的:

eyeglass:modules discovered modules
eyeglass:modules    :root(test)
eyeglass:modules    ├── eyeglass@1.2.1
eyeglass:modules    ├── eyeglass-sample@0.0.3
eyeglass:modules    └── true@2.2.1
eyeglass:modules     +0ms
eyeglass:functions functions discovered in module eyeglass:
• eyeglass-asset-uri($registered-assets, $relative-path)
• eyeglass-normalize-uri($uri, $type: web)
• eyeglass-uri-preserve($uri)
• eyeglass-uri-restore($uri)
• eyeglass-version($module: eyeglass)
• eyeglass-fs-absolute-path($fs-registered-pathnames, $path-id, $segments...)
• eyeglass-fs-join($segments...)
• eyeglass-fs-exists($absolute-path)
• eyeglass-fs-path-separator()
• eyeglass-fs-list-files($directory, $glob: '*')
• eyeglass-fs-list-directories($directory, $glob: '*')
• eyeglass-fs-parse-filename($filename)
• eyeglass-fs-info($filename)
• eyeglass-fs-read-file($filename) +13ms
eyeglass:functions functions discovered in module eyeglass-sample:
• hello($name) +1ms
eyeglass:functions all discovered functions:
• eyeglass-asset-uri($registered-assets, $relative-path)
• eyeglass-normalize-uri($uri, $type: web)
• eyeglass-uri-preserve($uri)
• eyeglass-uri-restore($uri)
• eyeglass-version($module: eyeglass)
• eyeglass-fs-absolute-path($fs-registered-pathnames, $path-id, $segments...)
• eyeglass-fs-join($segments...)
• eyeglass-fs-exists($absolute-path)
• eyeglass-fs-path-separator()
• eyeglass-fs-list-files($directory, $glob: '*')
• eyeglass-fs-list-directories($directory, $glob: '*')
• eyeglass-fs-parse-filename($filename)
• eyeglass-fs-info($filename)
• eyeglass-fs-read-file($filename)
• hello($name)
[19:25:56] Finished 'sass' after 97 ms
eyeglass:import true can be imported from ~/eyeglass-test/test/test.scss +5ms
{ [Error: Error: Could not import true from any of the following locations:
  ~/eyeglass-test/test/true.scss
  ~/eyeglass-test/test/true.sass
  ~/eyeglass-test/test/true.css
  ~/eyeglass-test/test/_true.scss
  ~/eyeglass-test/test/_true.sass
  ~/eyeglass-test/test/_true.css
  ~/eyeglass-test/test/true/index.scss
  ~/eyeglass-test/test/true/index.sass
  ~/eyeglass-test/test/true/index.css
  ~/eyeglass-test/test/true/_index.scss
  ~/eyeglass-test/test/true/_index.sass
  ~/eyeglass-test/test/true/_index.css]
  status: 1,
  file: '~/eyeglass-test/test/test.scss',
  line: 1,
  column: 9,
  message: 'Error: Could not import true from any of the following locations:
    ~/eyeglass-test/test/true.scss
    ~/eyeglass-test/test/true.sass
    ~/eyeglass-test/test/true.css
    ~/eyeglass-test/test/_true.scss
    ~/eyeglass-test/test/_true.sass
    ~/eyeglass-test/test/_true.css
    ~/eyeglass-test/test/true/index.scss
    ~/eyeglass-test/test/true/index.sass
    ~/eyeglass-test/test/true/index.css
    ~/eyeglass-test/test/true/_index.scss
    ~/eyeglass-test/test/true/_index.sass
    ~/eyeglass-test/test/true/_index.css',
      formatted: 'Error: Error: Could not import true from any of the following locations:
    ~/eyeglass-test/test/true.scss
    ~/eyeglass-test/test/true.sass
    ~/eyeglass-test/test/true.css
    ~/eyeglass-test/test/_true.scss
    ~/eyeglass-test/test/_true.sass
    ~/eyeglass-test/test/_true.css
    ~/eyeglass-test/test/true/index.scss
    ~/eyeglass-test/test/true/index.sass
    ~/eyeglass-test/test/true/index.css
    ~/eyeglass-test/test/true/_index.scss
    ~/eyeglass-test/test/true/_index.sass
    ~/eyeglass-test/test/true/_index.css
  on line 1 of test/test.scss
  >> @import "true";
     --------^
  ' } null

我已经尝试了几个潜在的眼镜依赖项,例如

  • 眼镜样品
  • 眼镜数学
  • 苏西
  • 真的

我对所有这些都遇到了相同类型的故障,它们似乎在调试输出中可用,但尝试@import按名称或目录@import中的任何内容对它们进行sass失败。

即使出现非常具体的说明可以导入的消息,我也会遇到这些失败:

eyeglass:import susy can be imported from ~/eyeglass-test/sass/_test.scss +14ms
...
Error: File to import not found or unreadable: susy.

如果我再次从头开始,我会遇到这个,我已经过去了(虽然我不记得如何):

> DEBUG=* gulp sass
[12:51:50] Requiring external module babel-register
[12:51:53] Using gulpfile ~/Projects/eyeglass-test/gulpfile.babel.js
[12:51:53] Starting 'sass'...
  eyeglass:modules discovered modules
  eyeglass:modules  :root(eyeglass-test)
  eyeglass:modules  ├── eyeglass@1.2.1
  eyeglass:modules  └── susy@2.2.12
  eyeglass:modules   +0ms
[12:51:53] 'sass' errored after 29 ms
[12:51:53] TypeError: this.main is not a function
    at EyeglassModule.init (~/eyeglass-test/node_modules/eyeglass/lib/modules/EyeglassModule.js:80:33)
    at ~/eyeglass-test/node_modules/eyeglass/lib/modules/EyeglassModules.js:83:9
    at Array.forEach (native)
    at EyeglassModules.init (~/eyeglass-test/node_modules/eyeglass/lib/modules/EyeglassModules.js:82:13)
    at new Eyeglass (~/eyeglass-test/node_modules/eyeglass/lib/index.js:35:16)
    at Eyeglass (~/eyeglass-test/node_modules/eyeglass/lib/index.js:18:13)
    at Gulp.<anonymous> (~/eyeglass-test/gulpfile.babel.js:7:19)
    at module.exports (~/eyeglass-test/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (~/eyeglass-test/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (~/eyeglass-test/node_modules/gulp/node_modules/orchestrator/index.js:214:10)

以上是用于说明目的的最简化的情况。我已经尝试过使用来自眼镜文档的替代品和问题,例如new Eyeglassandeyeglass.Eyeglasseyeglass.sassOptions()。我已经尝试过使用和不使用enableImportOnce: false. 我尝试通过眼镜选项手动添加模块。我已经尝试过使用和不使用engines. 我已经尝试过提供或不提供眼镜文档和问题importer中提到的默认值。我已经尝试过使用node-sassgulp-sasssass-true的 runner 方法(通过它true但不能导入其他任何东西,因为true会将自身添加到)。includePaths

我唯一没有尝试过的——尽管我很确定它会起作用——是手动创建我自己的includePaths配置以包含眼镜模块的 sass 目录,因为不必这样做是我感兴趣的两个原因之一在使用眼镜。我的印象是,通常不需要设置includePaths为使用眼镜模块,但是,假设它是由我正在做的事情引起的,我不清楚我创造了什么不可避免的常见情况所有这些一直要求我这样做的各种尝试。

交叉发布到https://github.com/sass-eyeglass/eyeglass/issues/164

4

1 回答 1

0

I was able to reproduce this several times, but had to put it down for a bit. When I came back to it and set up individual examples for the various things I tried, I discovered that I had gotten further than I'd thought and my main issues were:

  1. True is unique. There're still some parts of how to best work with True and eyeglass that I'm fuzzy on, but the main points are there.
  2. Eyeglass doesn't support transitive dependencies if they are devDependencies; module authors need to make sure to list any eyeglass dependencies in dependencies.

Here are all the examples I ultimately created for troubleshooting, in case they are useful to others.

https://github.com/morewry/sass-eyeglass-examples

于 2017-04-12T23:00:01.420 回答