Adding 'type': 'module'
to the package.json
enables ES 6 modules.
When you have 'type': 'module'
in the package.json
file, your source code should use import
syntax. When you do not have, you should use require
syntax.
Create a .env
file and add the following code:
PORT=8000
DBURI=mongodb+srv://arnabmunshi:<password>@nodejs.1vdau.mongodb.net/<dbname>?retryWrites=true&w=majority