0.0.4 • Published 4 months ago

@ibaraki-douji/nmm v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

Node Modules Mover

This project allow you to use a complete other directory for your node modules. You can even use multiple directories for your node modules. Or install them in differents drives.

⚠️ This is a personnal project to help me with my own projects. Use it if you want but i will not fix errors for you ⚠️

Installation

npm install -g @ibaraki-douji/nmm

Usage

nmm [command] [options]

Options:
  --version          output the version number
  --help             display help for command

Commands:
    init                     Create a new .nmm.json file
    install [package]        Install node modules
    add [path] [--create]    Add a new path to the .nmm.json file (folder without node_modules ending) and create the folder if --create is set
    remove [index]           Remove a path from the .nmm.json file
    list                     List all paths in the .nmm.json file (with index)
    default [index]          Set a path as default (install path of the modules)

Example

npm init -y
nmm init
nmm add "D:/Deps/Nodes/Project1" --create
nmm default 2
nmm install express

After the .nmm.json file will look like this:

{
  "moduleInstallPath": "D:/Deps/Nodes/Project1",
  "modulePath": [
    "C:/Users/user/Documents/Projects/YourRealProject"
    "D:/Deps/Nodes/Project1",
  ]
}

And the index.js file will look like this:

const express = require("express");
const app = express();
app.get("/", (req, res) => {
  res.send("Hello World!");
});
app.listen(3000, () => {
  console.log("Server started on port 3000");
});

Configuration

First init your node project with npm init -y and then run nmm init to create the .nmm.json file.

After you can add paths with nmm add [path] --create and remove them with nmm remove [index].

You can list all paths with nmm list and set the default path to install the modules with nmm default [index].

You can install node modules with nmm install [package] and run your project with a normal node project node [jsFile].

.nmm.json

This file is created by the nmm init command. You can edit it manually if you want.

{
  "moduleInstallPath": "C:/Users/user/Documents/Projects/YourRealProject",
  "modulePath": [
    "C:/Users/user/Documents/Projects/YourRealProject",
    "D:/Deps/Nodes/Project1",
  ]
}
  • moduleInstallPath: The path where the modules will be installed
  • modulePath: The paths where the modules will be searched

Why ?

I have lost my drive recently so i use my NAS with a network drive to store my projects. But if the dependencies are installed on the network drive it's very slow. So i use this to install the dependencies on my local drive and use them on the network drive.

Computer
  - C: (only carry the OS and some programs like node)
  - B: (local drive)
    - Dependencies
      - NodeJS
        - Project1
        - Project2
        - DiscordBot
  - D: (network drive)
    - Dev
      - NodeJS
        - Project1
        - Project2 (using Porject2 and DiscordBot dependencies)
        - DiscordBot

Next features

  • Add a command to uninstall the modules
  • Add a command to install all modules from a module path (ex: nmm install 1 will install all modules from the path with the index 1)
  • Add a command to install all modules from all module paths
  • Add a command to update all modules from all module paths
  • Add a command to update all modules from a module path
0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago