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.

Error: Non-whitespace before first tag

See original GitHub issue

Sorry to raise an issue with this name again, but I believe that this is not related to the BOM issue that was closed previously. I am wondering if I am doing something silly with my webpack config that is causing this:

WARNING in ./shared/components/svg-icon/icons/twitter.svg
Module build failed: Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: m
    at error (blah/node_modules/xml2js/node_modules/sax/lib/sax.js:651:10)
    at strictFail (blah/node_modules/xml2js/node_modules/sax/lib/sax.js:677:7)
    at beginWhiteSpace (blah/node_modules/xml2js/node_modules/sax/lib/sax.js:951:7)
    at Object.write (blah/node_modules/xml2js/node_modules/sax/lib/sax.js:1006:11)
    at Parser.exports.Parser.Parser.parseString (blah/node_modules/xml2js/lib/xml2js.js:508:31)
    at Parser.parseString (blah/node_modules/xml2js/lib/xml2js.js:7:59)
    at AnonymousObservable.__subscribe (blah/node_modules/svg-react-loader/lib/xml/parse.js:16:16)
    at AnonymousObservable.tryCatcher (blah/node_modules/svg-react-loader/node_modules/rx/dist/rx.js:63:31)
    at setDisposable (blah/node_modules/svg-react-loader/node_modules/rx/dist/rx.js:5845:44)
    at AnonymousObservable.Rx.AnonymousObservable.AnonymousObservable._subscribe (blah/node_modules/svg-react-loader/node_modules/rx/dist/rx.js:5862:9)

So you’ll notice the char it comes across is an ‘m’, so I decided to see what it was seeing and logged out before this line svg-react-loader/lib/xml/parse.js:16:16 and got this:

module.exports = __webpack_public_path__ + "d9fb6acead094090c1450fa6f4b6c5b7.svg";

It seems that the loader has already done its magic by this point. So why am I getting this warning? Is it running twice? This is how my loader is configured:

{
  test: /\.svg$/,
  loader: 'svg-react-loader',
},

Any help would be appreciated. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:7

github_iconTop GitHub Comments

49reactions
dannyk08ibcommented, May 4, 2018

this may be and old thread but I came across this same error, make sure you set a defined loader for the file. Especially if you have other loaders with svg definitions

import Icon from '-!svg-react-loader./icon/path/name.svg';
24reactions
chuckbergeroncommented, Dec 4, 2018

I had this same issue but am using a root import plugin, so mine ended up looking like:

import Icon from '-!svg-react-loader!src/assets/images/name.svg'

(note the 2nd bang ‘!’ after ‘-svg-react-loader’)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Non-whitespace before first tag in xmls2js · Issue #345 - GitHub
@fxlemire I have a feed Reader that I created for RDF, ATOM as well as RSS. It works fine for all three but...
Read more >
Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: 4
The culprit is the so-called Byte-Order-Mark (BOM), a 3-byte “Zero width no-break space” Unicode character which Windows systems automatically ...
Read more >
xml2js.js / sax.js: Non-whitespace before first tag - APImock
When looking into the XML directly and testing it e.g. with an XML validator everything seems fine. Turns out the culprit is the...
Read more >
How to parse XML from URL – problem with encoding
ERROR: Non-whitespace before first tag. Line: 0 Column: 1 Char: . I assume the problem is with encoding. Here are my two...
Read more >
Error: Non-whitespace before first tag. – Help Center - ABBYY
Hello, I need your help, I'm using processDocument Method for the JS example from GitHub...
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