How to Install a local module using npm?

0 votes
I have a downloaded module repo, I want to install it locally, not globally in another directory?

What is an easy way to do this?
Jul 9 in Node-js by kartik
• 20,980 points
31 views

1 answer to this question.

0 votes

Hello @kartik,

This is what worked for me:

npm pack + package.json

STEP 1: In module project, execute npm pack:

This will build a <package-name>-<version>.tar.gz file.

STEP 2: Move the file to the consumer project

Ideally you can put all such files in a tmp folder in your consumer-project root:

STEP 3: Refer it in your package.json:

"dependencies": {
  "my-package": "file:/./tmp/my-package-1.3.3.tar.gz"
}

STEP 4: Install the packages:

npm install or npm i or yarn

Now, your package would be available in your consumer-project's node_modules folder.

Hope it helps!!
Thank You!!

answered Jul 9 by Niroj
• 44,800 points

Related Questions In Node-js

0 votes
1 answer

How do I install a module globally using npm?

Hello @kartik, I found the output contained the ...READ MORE

answered Jul 16 in Node-js by Niroj
• 44,800 points
15 views
0 votes
1 answer

How to install a private NPM module without my own registry?

Hello @kartik, Try: cd somedir npm install . or npm install path/to/somedir somedir must ...READ MORE

answered Jul 20 in Node-js by Niroj
• 44,800 points
22 views
0 votes
1 answer

How to install a previous exact version of a NPM package?

Hello @kartik, If you have to install an ...READ MORE

answered Jul 8 in Node-js by Niroj
• 44,800 points
52 views
0 votes
1 answer

How to create a directory if it doesn't exist using Node.js?

Hello @kartik, Try: var fs = require('fs'); var dir = ...READ MORE

answered Jul 9 in Node-js by Niroj
• 44,800 points
42 views
0 votes
1 answer

How to write files in Node.js?

Hello @kartik, Currently there are three ways to ...READ MORE

answered Jul 8 in Node-js by Niroj
• 44,800 points
33 views
0 votes
1 answer

How to run Gulp tasks sequentially one after the other?

Hello @kartik, By default, gulp runs tasks simultaneously, ...READ MORE

answered Jul 12 in Node-js by Niroj
• 44,800 points
16 views
0 votes
1 answer

How to set environment variables from within package.json?

Hello @kartik, Set the environment variable in the ...READ MORE

answered Jul 13 in Node-js by Niroj
• 44,800 points
138 views
0 votes
1 answer

How to npm install to a specified directory?

Hello @kartik, You can use the --prefix option: mkdir -p ./install/here/node_modules npm ...READ MORE

answered Jul 15 in Node-js by Niroj
• 44,800 points
20 views
0 votes
1 answer

How TO install a local module using npm?

Hello @kartik, In the local module directory: $ cd ...READ MORE

answered Jul 13 in Node-js by Niroj
• 44,800 points
18 views
0 votes
1 answer

How to install a private NPM module without my own registry?

Hello @kartik, In your private npm modules add "private": true to ...READ MORE

answered Jul 13 in Node-js by Niroj
• 44,800 points
21 views