Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Kuhl
26,133 Points"Uncaught SyntaxError: Identifier 'exports' has already been declared"
I'm trying to set up my own module, just a basic library that makes it easier to use typical canvas functions. When I try to make my model like the one in the video, I keep getting this error, and it keeps claiming that the model name that I pass in is "not defined."
Here's the code:
let EasyCanvas = (function(exports) {
"use strict";
const exports = {
//.....contents
}
return exports;
})(EasyCanvas || {});
What am I missing?
1 Answer
Steven Parker
231,269 PointsThe identifier "exports" is already in use as the name of your passed-in argument. So with "strict" mode on, when you create a new constant with that same name, you get the "already in use" error.