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.

Uncaught TypeError: Cannot read property 'indexOf' of null

See original GitHub issue

Howdy, I am getting an error when using Browsersync, specifically when I’m using the css style injection feature, I’m following a tutorial. The autoupdate/refresh feature does not work when I change css styles. I rolled back to version 2.12.8. This error does not occur with 2.12.8. TIA.

The error: Uncaught TypeError: Cannot read property 'indexOf' of null

complete error message:

Uncaught TypeError: Cannot read property 'indexOf' of null
   

at Object.e.splitUrl (browser-sync-client.js?v=2.23.6:8)
   

 at Object.e.pathFromUrl (browser-sync-client.js?v=2.23.6:8)
   
 at browser-sync-client.js?v=2.23.6:8
    at browser-sync-client.js?v=2.23.6:8
  
  at Array.forEach (<anonymous>)
 
 at Object.e.pickBestMatch (browser-sync-client.js?v=2.23.6:8)
    
at t.reloadStylesheet (browser-sync-client.js?v=2.23.6:8)
    
at t.reload (browser-sync-client.js?v=2.23.6:8)
   
at r.<anonymous> (browser-sync-client.js?v=2.23.6:8)
    
at r.emit (browser-sync-client.js?v=2.23.6:8)

The version: browser-sync 2.23.6 The OS: win7 64-bit

my gulpfile:


var gulp = require('gulp'),
watch = require('gulp-watch'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
cssvars = require('postcss-simple-vars'),
nested = require('postcss-nested'),
cssImport = require('postcss-import'),
browserSync = require('browser-sync').create();

gulp.task('default', function() {
  console.log("Hooray - you created a Gulp task.");
});

gulp.task('html', function() {
  console.log("Imagine something useful being done to your HTML here.");
});

gulp.task('styles', function() {
  return gulp.src('./app/assets/styles/styles.css')
    .pipe(postcss([cssImport, cssvars, nested, autoprefixer]))
    .pipe(gulp.dest('./app/temp/styles'));
});

gulp.task('watch', function() {

  browserSync.init({
    notify: false,
    server: {
      baseDir: "app"
    }
  });

  watch('./app/index.html', function() {
    browserSync.reload();
  });

  watch('./app/assets/styles/**/*.css', function() {
    gulp.start('cssInject');
  });

});

gulp.task('cssInject', ['styles'], function() {
  return gulp.src('./app/temp/styles/styles.css')
    .pipe(browserSync.stream());
});

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
arnisjuragacommented, Dec 15, 2019

I had the same error. Only by debugging I found, that having empty “link” tag is crashing browsersync:

<link rel="stylesheet">

I think, You can easily reproduce this.

3reactions
marius-hicommented, Apr 6, 2020

I confirm what @arnisjuraga described earlier. I’m getting the same error in browser-sync 2.26.7 when having this tag on the page: <link id="templateCss" rel="stylesheet"> I use this tag to dynamically load additional css files in Javascript.

It seems that this was introduced in 2.22.0. As a work around I downgraded to a lower version such as 2.21.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'indexOf' of null ...
I'm populating a table with data - using fixed-data-table , which is a React.js component. However, that isn't so important at this stage....
Read more >
TypeError: Cannot read property 'indexOf' of null #130 - GitHub
I'm trying to get dynamic items into select option but I get this error [Vue warn]: Error in render: "TypeError: Cannot read property...
Read more >
How to fix "Uncaught TypeError: Cannot read property indexOf ...
The solution to fix Uncaught TypeError: Cannot read property 'indexOf' of undefined. There is a really simple fix for this JS error! All...
Read more >
T168621 CX1: "TypeError: Cannot read property 'indexOf' of ...
CX1: "TypeError: Cannot read property 'indexOf' of null" when translating a template ... Open console, enable pause on exceptions (also uncaught).
Read more >
Uncaught TypeError Cannot read property indexOf of undefined
Uncaught TypeError : Cannot read property 'indexOf' of undefined. Is there something wrong with the code? Thanks for your help.
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