简体   繁体   中英

Installing modules in node

I am trying to install a module in node and i have never done this before. I have downloaded the busboy module which is a folder named "busboy-master" coming with three subfolders and a few files. I have put the "busboy-master" folder inside C:\\Program Files\\nodejs\\node_modules

In a node command prompt I type: npm install busboy

At this point the console seems to be doing stuff but doesn't seem to give either error or confirmation.

Anyway, when I run my javascript I still get an error on the line that says: var busboy = require('busboy');

and the error from the console is : Error, cannot find module busboy.

I have also tried to put the busboy-master folder in this directory without luck: C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules.

I have never installed a module before and I can't find any walkthroughs on how to do this. Is there any steps I am missing or something more or different I should be doing?

Thanks!

There are two ways to install npm.

1.Local

npm install npm_name

If you want to use it on the specific application. You just go to root directory & use above command.

Scope for this npm is for that application only. If you want to use it on other application, you need to install again.

If use install locally, installation path will be with in same folder, inside the node_modules folder

2. Global

npm install -g npm-name

If you want to use it globally.Suppose you want to use one npm in every application. If you install globally, you don't need to install it again.

Ex. We will use express npm in every application. So we install globally & use it in every application.

Installation path of folder will be C:\\Users\\user_name\\AppData\\Roaming\\npm

Read up on the absolute bare-essential basics of node and npm. Flex your google-muscles. Here, i'll get you started. I googled "what is npm" and found this great introduction that answers your question.

Just delete the module busboy completely from your node module. Just go to node module directory and give command

npm install busboy

And in your js file write

 var busboy = require('busboy');

It will work for sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM