1

when I study a vuejs example, I came across this line in a javascript file:

exports.getLastTimeStr = (time, friendly) => {

I only encountered javascript syntax such as "module.export" or "export default", I didn't see code like above. As a result, I got warning like:

11:15-20 "export 'default' (imported as 'utils') was not found in './libs/utils'

Googling led to this link: Using "Exports." in Javascript?

it appears to be a commonJS stuff but I was unable to go further from here, nor a solution was found.

J.E.Y
  • 1,173
  • 2
  • 15
  • 37
  • Initially, if you don’t reassign `module.exports`, it’s an empty object also called `exports`. Assigning to properties of `exports` is a short way of assigning to properties of `module.exports`. If you’re using ESM, use an ESM export instead – `export const getLastTimeStr = …`. (Note that it still needs to be imported correctly, like `import { getLastTimeStr } from …`.) – Ry- Oct 12 '18 at 05:01

1 Answers1

0

exports points to the same object reference as module.exports.

From the code snippet in your question.

exports.getLastTimeStr = (time, friendly) => {

and

module.exports.getLastTimeStr = (time, friendly) => {

Both would mean the same because both have the same object reference.

Read more here Difference between "module.exports" and "exports" in the CommonJs Module System

vatz88
  • 2,422
  • 2
  • 14
  • 25