How to create a new Node.js project

Creating a new Node.js project requires proper initialization and directory structure for building scalable applications. As the creator of CoreUI, a widely used open-source UI library, I’ve created hundreds of Node.js projects for build tools, APIs, and enterprise backend services. From my expertise, the most efficient approach is to initialize with npm and create a clean project structure. This method ensures proper dependency management and maintainable code organization.

Initialize a new directory with npm init and create basic project structure.

mkdir my-project && cd my-project
npm init -y
mkdir src
echo 'console.log("Hello Node.js!")' > src/index.js
node src/index.js

The mkdir command creates your project directory, then cd navigates into it. The npm init -y command initializes a new Node.js project with default settings, creating a package.json file. Creating a src directory organizes your source code, and the basic index.js file serves as your application entry point.

Best Practice Note:

This is the same approach we use in CoreUI backend projects for clean organization.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
The Wacky World of JavaScript: Unraveling the Oddities
The Wacky World of JavaScript: Unraveling the Oddities

How to Open Link in a New Tab in HTML?
How to Open Link in a New Tab in HTML?

How to migrate CoreUI React Templates to Vite
How to migrate CoreUI React Templates to Vite

How to set focus on an input field after rendering in React
How to set focus on an input field after rendering in React

Answers by CoreUI Core Team