Skip to content

Uncaught TypeError: Cannot read property 'replace' of null #381

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

Closed
cdbkr opened this issue Jan 21, 2016 · 22 comments
Closed

Uncaught TypeError: Cannot read property 'replace' of null #381

cdbkr opened this issue Jan 21, 2016 · 22 comments

Comments

@cdbkr
Copy link

cdbkr commented Jan 21, 2016

Hi, with version 1.14.1 I'm receiving this error:

Uncaught TypeError: Cannot read property 'replace' of null

I'm using an inline script in the index.html to load the .JS file (which is in the folder declared by publicPath) and I enabled the hot module replacement to receive updates.

Using version 1.14.0, it works fine (so at the moment I am not updating the webpack-dev-server module to 1.14.1).

@matiss
Copy link

matiss commented Jan 22, 2016

I have the same situation as the OP. I also have a inline script which loads the bundle and I am getting the same error when I upgraded Webpack dev server to 1.14.1. Downgrade fixed the error, though.

@techird
Copy link

techird commented Jan 26, 2016

Same problem, seems a problem with 1.14.1, 1.14.0 is alright.

@reebalazs
Copy link

I can confirm that it breaks when you have a script with no src tag. This is a showstopper if you have injected js into the html.

It breaks on this line:

var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");

1.14.0 works for me too.

#372 is a duplicate.

@wedgex
Copy link

wedgex commented Feb 5, 2016

I'm getting the same error, downgrading to 1.14.0 temporarily as a work around.

Assuming the dev server script is the last script on the page seems to be the issue. 3d3c000

@Nebukam
Copy link

Nebukam commented Feb 20, 2016

Same issue happened to me. Downgraded as well, works like a charm with 1.14.0

@EvHaus
Copy link

EvHaus commented Mar 2, 2016

FYI: This is happening when you have a <script /> tag in your code that doesn't have a src attribute.

@adamhartford
Copy link

I was able to work around this with a hack-ish change:

<script>
    document.currentScript.src =''; // So that the script executes, but later has a src.

    // ... Do rest of work.   
</script>

@damonmcminn
Copy link

I also have this issue. The sole script tag on my page contains a src attribute:

<script src="bundle.js"></script>

Downgrading to 1.14.0 solved the issue.

@marcelpanse
Copy link

Same problem here because of the Google Tag Manager script in the index.html

tofuness pushed a commit to tofuness/Toshocat that referenced this issue Apr 19, 2016
Do not upgrade webpack-dev-server to >=1.14.1
webpack/webpack-dev-server#381
@JustinMGaiam
Copy link

This issue affected us as well. Fixing it required setting webpack-dev-server to 1.14.0 in package.json and then the running npm install again.

@incleaf
Copy link

incleaf commented May 27, 2016

Same problem with 1.14.0

@idoco
Copy link

idoco commented Jun 5, 2016

Just to point out for anyone else having the same issue -
For me this issue occurred because of using the Poper Blocker chrome extension. I didn't have no script tag without 'src' attribute in the page I was working on, so it was very confusing to understand that this extension injects a script tag (without an 'src' attribute) during the page loading.

I have disabled the extension until this issue will be fixed.

@adrianmcli
Copy link

@idoco I can confirm that the popup blocker extension is causing the error for me. Not sure why that is though.

@idoco
Copy link

idoco commented Jun 5, 2016

@adrianmc Yes, I think this is just because the extension injects a script tag with no 'src' attribute to the page which is the real root cause.

@damonmcminn
Copy link

@idoco thanks!

My exact issue. Whitelisting the appropriate dev domains solves the issue.

@vutran
Copy link

vutran commented Jun 22, 2016

Also getting this problem with the similar script injections. The solution provided above (downgrading to 1.14.0) works for me.

@imbhargav5
Copy link

I had this error because of a 'defer' attribute in my script tag.

@kamono
Copy link

kamono commented Jul 27, 2016

I had this issue when the variable I used was equal to null. Just added a check to perform .replace if not null, and it works now. Hope this helps someone.

@SpaceK33z
Copy link
Member

Dupe of #117.

@lovemyliwu
Copy link

just for somebody rush into this issue:

i missed there is no correct entry in webpack config file after i git check out other branch

the webpack still watch old entry

@maxifjaved
Copy link

faced the same issue. I just clear the cache data, it works.

@charlest7
Copy link

yeah

@webpack webpack locked as resolved and limited conversation to collaborators May 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests