DEV Community

Discussion on: Import Local JSON In Node.js v8.5 Experimental Modules

Collapse
 
danieljsummers profile image
Daniel J. Summers

I'm guessing the new mjs thing is an all-or-nothing thing? I tried just adding the --experimental-modules flag on my existing app, and it didn't like it. However, I've finally had success getting my Vue front-end to send the data to the API, it process it, and return something that makes sense. (woo hoo!)

I'll defer playing with modules for a bit, though I do have an .mjs file there (you can old-style require them, too, if you add the extension) to remind me.

Thread Thread
 
geoff profile image
Geoff Davis

I'm guessing the new mjs thing is an all-or-nothing thing?

I believe that is the case. To be honest I do not know much about how Node works behind-the-scenes, but it appears that switching between --experimental-modules and CommonJS modules would be like using straight ES201* code or sending it through Babel.

... I do have an .mjs file there (you can old-style require them, too, if you add the extension) ...

Good to know! I like it because I don't have to switch headspace anymore when working on frontend and backend code.