1. Use npm and Local node_modules
By default, Node.js projects are isolated at the project
level through their node_modules directory. When you run npm install in a
project, all dependencies are installed locally in the project's node_modules
folder.
Steps:
- Create
a new project directory:
bash
mkdir my-nodejs-project
cd my-nodejs-project
- Initialize
a new package.json file:
bash
npm init -y
- Install
dependencies:
bash
npm install kafka-node google-protobuf
- All
dependencies will be stored locally in the node_modules folder, and your package.json
will track them. This isolates the project environment.
- To run
your script:
bash
This is equivalent to creating a Python virtual environment,
as dependencies will only affect the current project.
No comments:
Post a Comment