JS ā€¢ can you use ā€œrequireā€ in vanilla JS or is it for backend only? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

JS ā€¢ can you use ā€œrequireā€ in vanilla JS or is it for backend only?

I want to know if the require is usable in front end to import the whole JS file - instead of using import.

22nd Dec 2021, 4:03 AM
Ginfio
Ginfio - avatar
1 Resposta
+ 1
require is used to import Nodejs files only, you can also use import in place of require and vice-versa but only one at a time in whole application by altering type key in package.json Note: you have to use only one in whole application both can not be simultaneously used. And in front-end i haven't ever used require but i guess we can configure it to that if we want but it isn't industry standard.
23rd Dec 2021, 5:07 AM
Anshuman Singh
Anshuman Singh - avatar