General concept of npm and Browserify

183 views Asked by At

I have been following the instructions on the vis.js Github repository to do a custom build of the library. It suggests using Browserify… I have never used Node.js, npm or Browserify and I'm only just starting to get the concept of what they do.

I have been trying to compile the library using the following command

browserify custom.js -o vis-custom.js -s vis

But I keep getting errors like

Error: Cannot find module 'hammerjs' from '/path/to/folder/vis-master/lib/module'

It seems like the only way to get around this error is to install the module via npm. e.g.

npm install hammerjs

But as soon as I install a module this way another one generates an error.

My question is… am I meant to manually install each module until the errors go away or is npm/Browserify meant to install these automatically? If so why aren't they installing?

1

There are 1 answers

0
Jos de Jong On

All dependencies of node.js projects are listed in the file package.json in the root of the project. To install all dependencies (with correct versioning) run:

npm install

To update all dependencies, run:

npm update