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.

"2 definitions" when using module.exports to export a function wrapped in {}

See original GitHub issue
  • VSCode Version: 1.28.2
  • OS Version: macOS 10.14

I noticed there are several issues opened against “2 definitions”, noticeably https://github.com/Microsoft/vscode/issues/51459 & https://github.com/Microsoft/TypeScript/issues/24861

But I don’t think my issue is the same (I don’t use ts or react, just nodejs code). It happens when I export like this

function downloadVoice() {
...
}

module.exports = {
    downloadVoice
}
// If I export like this it will not happen
// module.exports = downloadVoice

But when I hover over to the place when the function is called, vscode can show the definition correctly,

2 inspection

The 2 definitions warning:

ks3test_js_ _inspection

Does this issue occur when all extensions are disabled?: Yes

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
qiulangcommented, Nov 16, 2018

Hi I believe this bug has been there for a long time and it is quite annoying. Do you have plan to fix it recently ?

1reaction
qiulangcommented, Nov 14, 2018

I tested 1.29, it still has the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

module.exports – How to Export in Node.js and JavaScript
In this article, I will show you how to share functions and values by exporting and importing modules in Node.js.
Read more >
Understanding module.exports and exports in Node.js
In this article, I'll examine how to work with modules in Node.js, focusing on how to export and consume them.
Read more >
The difference between module.exports and exports in Node.js
When we want to export a function or a primitive value (string, number, etc.), we need to reassign module.exports . Reassigning exports variable ......
Read more >
Use Module.exports to Keep Node.js Code Organized - Medium
Let's export a single function that multiplies a number by 2 and use it in our index.js file: // helpers.js module.exports = function(x)...
Read more >
Difference between "module.exports" and "exports" in the ...
module is a plain JavaScript object with an exports property. exports is a plain JavaScript variable that happens to be set to ...
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