生成源映射时出错 - grunt和sass配置 [英] Error generating source map - grunt and sass configuration

查看:102
本文介绍了生成源映射时出错 - grunt和sass配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用咕噜声来使用sass。


节点: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 =函数(grunt){
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
sass:{
dist:{
文件:{
'style / style.css':'sass / home.scss'
}
}
},
手表:{
css:{
文件:'** / *。sc ss',
tasks:['sass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['watch']);
}

现在如果我尝试了grunt命令,我得到了下面的错误。任何帮助?



运行:grunt或grunt手表或grunt sass
$ b

error:

 运行sass:dist(sass)任务
错误:源地图:无法确定源
样式表的公开网址。
没有文件名可用,所以没有任何源地图将
链接到。
标准输入
使用--trace进行回溯。
警告:错误:生成源地图的错误:无法确定t
源样式表的公共URL。
没有文件名可用,所以没有任何源地图将
链接到。
标准输入
使用--trace进行回溯。使用--force继续。

由于警告而中止。

有什么想法?

解决方案

看起来你没有安装指南针。您可以运行 gem install compass 。在您的原始示例中,您的grunt文件设置为使用指南针,该指南针可让您访问指南针混合功能和功能。



现在你的代码看起来很好,应该可以工作,似乎没有找到你的文件。当我在一台电脑旁边时,我会继续使用它。



与此同时,您可以尝试 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 来更新所有过期的软件包。


I am trying to use sass with grunt. I have installed ruby, sass and grunt in my path.
The versions are,

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

my package json is,

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

my grunt file is,

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']);
}

Now if i tried "grunt" command, i am getting the below error. Any help?

run: grunt or grunt watch or grunt sass

error:

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.

any idea?

解决方案

Looks like you don't have compass installed. You can run gem install compass. In your original example you had your grunt file set up to use compass which would have given you access to compass mixins and features.

Your code looks fine now and should work but seems to not be finding your files. I'll GI e it a go as well when I'm next to a computer.

In the meantime you can try the sourcemap: none option on the sass task.

Update:

Works perfectly fine for me. Could you run tree -I node_modules and post the output(unless you think there's any sensitive info) just to double check the files are in the right place?

I expect it to look something like this

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

Second update: Your packages seem significantly older than what's in my fresh setup. Either try starting from scratch or do the following:

Install npm-check-updates

npm install npm-check-updates 

And then run the following

  • npm-check-updates will tell you which packages are outdated
  • npm-check-updates -u will update those packages in your package.json
  • npm update to update all your outdated packages.

这篇关于生成源映射时出错 - grunt和sass配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆