gpt4 book ai didi

ruby - 生成源映射时出错 - grunt 和 sass 配置

转载 作者:数据小太阳 更新时间:2023-10-29 07:37:45 25 4
gpt4 key购买 nike

我正在尝试将 sass 与 grunt 一起使用。我已经在路径中安装了 ruby​​、sass 和 grunt。
版本是,

node: 0.10.20
npm: 1.3.11
grunt-cli: 0.1.13
grunt: 0.4.5
sass: 3.4.4

我的包json是,

"private": true,
"devDependencies": {
"express": "4.x",
"grunt": "~0.4.1",
"grunt-contrib-sass": "~0.3.0",
"grunt-contrib-watch": "~0.4.4"
}

我的 grunt 文件是,

module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'style/style.css' : 'sass/home.scss'
}
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['watch']);
}

现在,如果我尝试“grunt”命令,我会收到以下错误。有帮助吗?

运行:grunt 或 grunt watch 或 grunt sass

错误:

Running "sass:dist" (sass) task
Error: Error generating source map: couldn't determine public URL for the source
stylesheet.
No filename is available so there's nothing for the source map to link
to.
on line of standard input
Use --trace for backtrace.
Warning: Error: Error generating source map: couldn't determine public URL for t
he source stylesheet.
No filename is available so there's nothing for the source map to link
to.
on line of standard input
Use --trace for backtrace. Use --force to continue.

Aborted due to warnings.

有什么想法吗?

最佳答案

您似乎没有安装指南针。您可以运行 gem install compass。在您的原始示例中,您将 grunt 文件设置为使用 compass,这将使您能够访问 compass mixins 和功能。

您的代码现在看起来不错,应该可以工作,但似乎找不到您的文件。当我在电脑旁边时,我也会尝试一下。

与此同时,您可以在 sass 任务上尝试使用 sourcemap: none 选项。

更新:

非常适合我。您能否运行 tree -I node_modules 并发布输出(除非您认为有任何敏感信息)只是为了仔细检查文件是否在正确的位置?

我希望它看起来像这样

.
├── Gruntfile.js
├── package.json
├── sass
│   └── style.scss
└── style
├── style.css
└── style.css.map

第二次更新:您的包裹似乎比我的新设置中的要旧得多。尝试从头开始或执行以下操作:

安装 npm-check-updates

npm install npm-check-updates 

然后运行下面的

  • npm-check-updates 会告诉你哪些包已经过时了
  • npm-check-updates -u 将更新您的 package.json
  • 中的那些包
  • npm update 更新所有过时的包。

关于ruby - 生成源映射时出错 - grunt 和 sass 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26501454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com