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.

TypeError: must be an object

See original GitHub issue

I have the following in the webpack.config.js:

module.exports = {
  entry: ["./utils", "./app.js"],
  output: {
    filename: "bundle.js"
  },
  module: {
  loaders: [
    {
      test: /\.svg$/,
      loader: 'svg-sprite'
    }
    ]
  },
  watch: true
}

In the same directory of my app.js file I have the legoMan.svg file. In the app.js file I have:

var id = require('svg-sprite!./legoMan.svg');
console.log('App loaded');

When I run webpack I get the following:

ERROR in ./~/svg-sprite-loader!./legoMan.svg
Module build failed: TypeError: Must be an object
    at exports.objectToAttrString (/webpack-test/node_modules/svg-sprite-loader/lib/utils.js:6:11)
    at SVGDocument.toString (/webpack-test/node_modules/svg-sprite-loader/lib/svg-document.js:29:18)
    at Object.module.exports (/webpack-test/node_modules/svg-sprite-loader/index.js:47:17)
 @ ./app.js 2:9-44

I have searched for this error, and found that for someone it was because they had another loader conflicting with svgs, however in my case the only loader that I have specified is svg-sprite. Does anyone have some insight as to why I might be getting this error?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
kisenkacommented, Apr 11, 2016

Hi guys! Sorry for the delay. You trying to process SVG files twice: first in Webpack config, and then in require statement. If you just require file require('./legoMan.svg'); - all works.

0reactions
princedcommented, Apr 11, 2016

🙈

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module build failed: TypeError: Must be an object · Issue #1067
Environment mac node 6.9.2 webpack: 2.x antd-mobile version:1.0.6 WARNING in ./~/antd-mobile/lib/icon/style/assets/right.svg Module build ...
Read more >
TypeError - JavaScript - MDN Web Docs
TypeError is a serializable object, so it can be cloned with structuredClone() or copied between Workers using postMessage() . Constructor.
Read more >
node TypeError: options must be an object - Stack Overflow
I'm getting the error TypeError: options must be an object . I'm working through Chapter 4 of Node.js Design Patterns and on the...
Read more >
How to Fix TypeError: Null is Not an Object in JavaScript
The JavaScript error TypeError: null is not an object occurs when a property is accessed or a method is called on a null...
Read more >
The JSON object must be str, bytes or bytearray not Response
The Python TypeError: the JSON object must be str, bytes or bytearray, not Response occurs when we pass a `Response` object to the ......
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