question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undefined variable error but variable is indeed defined

See original GitHub issue
//_variable.scss
$blue-base: #66ccff;
$blue-dark: darken($blue-base, 10%);
$blue: $blue-base;
$blue-light: lighten($blue-base, 10%);
$blue-lighter: lighten($blue-base, 20%);
$blue-lightest: lighten($blue-base, 25%);

$link-color: $blue-dark;
$link-some-active-color: $blue;
// _global.scss
a {
    color: $link-color;
    text-decoration: none;

    &:hover, &:active, &:focus {
        color: $link-some-active-color;
    }
}

Error:

events.js:141
      throw er; // Unhandled 'error' event
      ^
Error: src/sass/_global.scss
Error: Undefined variable: "$link-some-active-color".
        on line 20 of src/sass/_global.scss
>>         color: $link-some-active-color;
   ---------------^

I am using Gulp.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

118reactions
majidzenocommented, Mar 1, 2018

@manix I faced the same issue with Sass, in my case the error was because I included the variables file after the other file where I used them, you could try doing this, reorder files import, make the variables file at the top.

24reactions
manixcommented, Dec 27, 2017

@guoyunhe can you elaborate?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Undefined variable error while the variable was indeed ...
My question is basically the same as describe here (see link) , but the answer did not explain things well and did not...
Read more >
How do I fix error "undefined variable" in php, when I have ...
I'm trying to define a class of Sphere, which can calculate various aspects of a sphere given its radius. However, I'm getting an...
Read more >
Undefined variable error in scss while compiling using sass ...
I'm new to the sass ecosystem and I'm facing a really annoying issue. ... Undefined variable error but variable is indeed defined.
Read more >
When saving a nav-menu I get error messages about ...
Hi, Whan I save a nav-menu (on wp-admin/nav-menus.php), I get error messages: Notice: Undefined variable: youtube_details in…
Read more >
7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
Undefined value primitive value is used when a variable has not been assigned a value. The standard clearly defines that you will receive ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found