How to manually install node.js module?

I want to upload a file to s3 in order to run the download program from this article: http://www.componentix.com/blog/9

To do this, I need to install a multi-page module. https://github.com/isaacs/multipart-js

But, by doing npm install multipart, it gives an error

How do I install this multi-page module so that I can run this program?

+23
file-upload multipart
Apr 25 2018-11-12T00:
source share
2 answers

Download the lib folder from https://github.com/isaacs/multipart-js (including all files inside it).

Put all these files next to your host application in the same folder.

At the top of the application file where you have included other modules, such as HTTP, etc. Add this>

var multipart = require("./multipart")

+21
Apr 25 '11 at 17:05
source share
— -

You can download the full repo (and not just the lib folder) into your application under a folder called node_modules .

Once you do this, your require will be simple:

 var multipart = require('multipart'); 

This is due to the way node resolves module dependencies. It will always look for the node_modules directory in the root of your application (and a few other places).

It is important that you download the complete repo, not just the lib folder, if you plan to use it this way, since the package.json file is used to find the main entry point.

  { "name" : "multipart" , "version" : "0.0.0" , "description" : "A JavaScript library for parsing and writing multipart messages" , "contributors" : [ "Isaac Z. Schlueter <i@izs.me>" , "John Wright <mrjjwright@gmail.com>" ] , "repository" : { "type" : "git" , "url" : "http://github.com/isaacs/multipart-js.git" } , "main" : "lib/multipart" } 

The advantage of this is compatibility using npm install locally on your dev machine.

You can also download the github tar file. Click the Download button and deploy it using your application. Once this is done on your server, you can run

 npm install <path-to-the-tar-file> 

This will install multipart on the machine for you.

+29
Aug 17 2018-11-18T00:
source share



All Articles