Error generating source map - grunt and sass configuration

北慕城南 提交于 2019-12-05 01:16:03

问题


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?


回答1:


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.



回答2:


updating node modules helped..

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.



来源:https://stackoverflow.com/questions/26501454/error-generating-source-map-grunt-and-sass-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!