Uncaught ReferenceError: exports is not defined
See original GitHub issueversion :beta0.264
myscript.js code
exports.setText = function() { var el= document.getElementbyId('demo') el.innerHTML = 'hello'; };
html code
`<!DOCTYPE html>
<h1>test login </h1>
<p id="demo">
test tcp
</p>
<button type="button" onclick='sendlidardata()'>login</button>
<button type="button" onclick='testFunction()'>test</button>
<script type="text/javascript" language="javascript" src='./myscript.js'>
var myscript = require('./myscript.js');
// 将`el`元素传入Node函数
myscript.setText();
// "hello"将显示在`el`标签中
</script>
</body>
</html>`
then ,I get an error ,Uncaught ReferenceError: exports is not defined
Thankyou ,I am a new one .hope your answer.Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Typescript ReferenceError: exports is not defined
I had the error "exports is not defined" coming from an imported NPM module. Changing my typescript config did nothing as I had...
Read more >How to fix ReferenceError: exports is not defined TypeScript
If you are getting the error for code that runs in the browser, try defining a global exports variable above the script tags...
Read more >Uncaught ReferenceError: exports is not defined : r/typescript
Getting this error for some dumb reason i'm sure. Uncaught ReferenceError: exports is not defined. at app.js:2. (anonymous) @ app.js:2. all ...
Read more >exports is not defined" in browser : WEB-26773
Typescript compiler outputs wrong javascript module format, giving "ReferenceError: exports is not defined" in browser ; "use strict"; Object.defineProperty ...
Read more >visual studio typescript "Uncaught ReferenceError: exports is ...
HTML : visual studio typescript " Uncaught ReferenceError: exports is not defined at.
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
@Ants-double , please try oliverlife’s advice. It’s ok for me.
change <script type="text/javascript" language="javascript" src='./myscript.js'> to <script type="text/javascript" language="javascript">