Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'match' of null #34

Open
orelmi opened this issue Mar 6, 2017 · 6 comments
Open

TypeError: Cannot read property 'match' of null #34

orelmi opened this issue Mar 6, 2017 · 6 comments

Comments

@orelmi
Copy link

orelmi commented Mar 6, 2017

I get this error when building with gulp.

    .map(function (val) {
     ^

TypeError: Cannot read property 'match' of null
at C:\Users\xxxx\node_modules\progeny\index.js:106:21
at Array.map (native)
at parseDeps (C:\Users\xxxx\node_modules\progeny\index.js:104:10)
at C:\Users\xxxx\node_modules\progeny\index.js:270:9
at tryToString (fs.js:455:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)

I changed the code like that ( if (val != null) added) and it works fine. Please, tell me why val can be . If the change is correct add it to the repository.

(index.js) at line 104

.map(function (val) {
var last = multipass[multipass.length - 1];
if (val != null)
return val.match(last)[1];
});

Thanks

@es128
Copy link
Owner

es128 commented Mar 6, 2017

Can you show me the source file and settings that caused the error to begin with? Was it a sass file using the built-in settings?

@ln-e
Copy link

ln-e commented Apr 20, 2017

I suppose i have the same problem.
My scss file starts with

@import '../../global/home';
@import url('http://fonts.googleapis.com/css?family=Russo+One&subset=cyrillic');
#page {
  @include gradient-bg(#03254b #012652);
}

And it fails

node_modules/progeny/index.js:106
          return val.match(last)[1];
                    ^

TypeError: Cannot read property 'match' of null
    at ./node_modules/progeny/index.js:106:21
    at Array.map (native)
    at parseDeps (./node_modules/progeny/index.js:104:10)
    at run (./node_modules/progeny/index.js:313:7)
    at ./node_modules/progeny/index.js:329:11
    at tryToString (fs.js:456:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
Segmentation fault: 11

But if i change like so

@import url('http://fonts.googleapis.com/css?family=Russo+One&subset=cyrillic');
@import '../../global/home';
#page {
  @include gradient-bg(#03254b #012652);
}

or so

@import '../../global/home';
@import url('http://fonts.googleapis.com/css?family=Russo+One&subset=cyrillic');
.another {
  content: ''; // <- quotes here
}
#page {
  @include gradient-bg(#03254b #012652);
}

or so

@import '../../global/home';
@import url('http://fonts.googleapis.com/css?family=Russo+One&subset=cyrillic');
#page {
  // @include gradient-bg(#03254b #012652);
}

it works.

@wmnnd
Copy link

wmnnd commented Jun 14, 2017

I have encountered the same problem using sass-brunch.

My scss file starts like this:

@import "compass/reset";
@import "compass/typography/vertical_rhythm";
@import url("https://fonts.googleapis.com/[…]");

This made progeny throw the following error:

error: Compiling of scss/styles.scss failed. TypeError: Cannot read property 'match' of null
  at ./node_modules/progeny/index.js:106:21
  at Array.map (native)
  at parseDeps (./node_modules/progeny/index.js:104:10)
  at run (./node_modules/progeny/index.js:313:7)
  at SassCompiler.progeny (./node_modules/progeny/index.js:320:7)
  at ./node_modules/micro-promisify/index.js:8:14
  at SassCompiler.<anonymous> (./node_modules/micro-promisify/index.js:6:10)
  at SassCompiler.compile (./node_modules/sass-brunch/index.js:208:17)

However, when I change the beginning of the file to

@import url("https://fonts.googleapis.com/[…]");
@import "compass/reset";
@import "compass/typography/vertical_rhythm";

or

@import "compass/reset";
@import url("https://fonts.googleapis.com/[…]");
@import "compass/typography/vertical_rhythm";

everything works without problems.

@VladimirKasatkin
Copy link

It looks like this error appears when we have only one import from url in file:

//---------------------------------------------------------
// Global UI Styling
//---------------------------------------------------------
@import 'https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700';

If I add extra import from empty file (I called it "_nothing.scss" and put in the same folder) then the error goes away.

//---------------------------------------------------------
// Global UI Styling
//---------------------------------------------------------
@import 'https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700';
@import 'nothing';

@thecristen
Copy link

I've got this too with using sass-brunch, but it happens when I import the gutenberg library. Turms out its config has a conditional import url statement. Thanks @wmnnd and @VladimirKasatkin for helping me figure out that one...

@yama-dev
Copy link

yama-dev commented Dec 5, 2018

Why do not you try to fix it as follows?

progeny()

progeny({
  multipass: [
    /@import[^;:]+;/g,
    /\s*['"][^'"]+['"]\s*,?/g,
    /(?:['"])([^'"]+)/
  ]
})

Exclude import path including ":"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants