TypeError: must be an object
See original GitHub issueI 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:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.🙈