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

时间:2014-10-22 06:26:55

标签: ruby node.js sass gruntjs npm

我正在尝试使用saru和grunt。我在路上安装了红宝石,萨斯和咕噜声 版本是,

  

节点:0.10.20
    npm:1.3.11
    grunt-cli:0.1.13
    咕噜: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.

任何想法?

2 个答案:

答案 0 :(得分:3)

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

您的代码现在看起来很好并且应该可以工作,但似乎找不到您的文件。当我在电脑旁边的时候,我也会感激不尽。

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

答案 1 :(得分:-2)

更新节点模块帮助..

npm-check-updates将告诉您哪些软件包已过时 npm-check-updates -u将更新package.json中的那些包 npm update更新所有过时的软件包。