-
The uri parameter to openUri() must be a string, got “undefined”. Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string – ERROR SOLVED
First of all, check whether you’ve installed the dotenv npm package. If not, install the dotenv package like so: Next, import dotenv inside your main server file ( like app.js or server.js file) like so : See whether your mongoose connection string is properly enabled like the example below : You should be connected to…
-
Environment Variables in NodeJS – All Info
Inside your NodeJS app you’ll have an environment variable (which is inside the root of your app folder as an .env file). This file stores critical info like the connection string which includes username and password to connect to your database such as MongoDB. It can also include other security info like JWT token numbers.…
-
NodeJS – MongoDB Sign Up and Login Web App Project
This is a basic full stack website wherein I’ll create a basic webpage in which users can sign up using an email and password, store the email and password in MongoDB database, login in to the user account dashboard using the same credentials and logout. This way you can learn the foundations to create a…
-
Creating server and Dynamic Routing in Express for starters
Here’s the code syntax for dynamic routing and server creation in express JS : Here’re the steps involved:
-
Dynamic Routing – Handling User Request in Vanilla NodeJS
Here’s a simple example of how you can dynamically route a server in pure vanilla NodeJS without any packages : Steps :
-
Important NPM packages you’ll need to build complex backends with NodeJS
Whether you’re learning backend development (with nodeJS) or trying to build complex back-end while using NodeJS, keep a note of the following NPM packages. You might need all or many of them in you backend development journey. Here they are: Express JS Express is a powerful and flexible web framework for NodeJS. It’s designed to…
-
How to create and run your very first simple HTTP server in NodeJS?
The first thing to do is to create a JS file inside your code editor. Next we write the following codes : In the above code we’ve imported the HTTP Module which is required for creating the server. In the following steps, let’s write some more codes : In the above code block we’ve used…
-
How to Read and Write files using NodeJS?
First import the build-in file system module like so : Synchronous Way Now, in order to use the fs (file-system) module to read a file, use the following code syntax : Now if you log the file above to the console, it will read and display the suitable file. Let’s now say you want to…
-
Getting started with NodeJS REPL
First go to the NodeJS website and download a suitable version of NodeJS on your system. I would recommend you use an LTS version in order to keep getting long term support and updates. Next, test whether you’ve NodeJS installed on your system by running the following terminal commands : To type and run node…
-
What is NodeJS and why should you use it as a JavaScript developer?
NodeJS is a JavaScript runtime environment which is built on the Google’s open-source V8 JavaScript engine. Now, what does that actually mean? Let’s explain… Any browser would understand HTML, CSS and JavaScript on the front-end. Whatever you write, whether it’s pure JavaScript or any of it’s libraries or frameworks like bootstrap, React or Angular, it’s…