11

I'm getting this error:

Error: Cannot find module 'browserify'

When I add this line to my app/server.js file:

var browserify = require('browserify'); 

Now I'm still new to Node, but I think I installed it correctly, via

npm install -g browserify 

as per their docs.

I'm pretty sure this is the command to check my global modules:

D:\Websites\MySite> npm ls -g C:\Users\Mark\AppData\Roaming\npm ├─┬ [email protected] │ ├─┬ [email protected] │ │ └── [email protected] 

It lists browserify there. So why can't I require it?

5
  • 1
    Possible duplicate of stackoverflow.com/questions/9587665/… Commented Jan 23, 2013 at 4:38
  • 1
    Oh..well. Installing it without -g made it work... but if -g doesn't install libs globally, why do some many libraries recommend it? I mean, if it adds it to the path so you can call some of their tools via command-line, that's great, but shouldn't they be recommending you run both with and without -g then? Commented Jan 23, 2013 at 4:40
  • 1
    Modules are typically recommended to be installed globally when they need to be used from the command line. But any module that is required from your code needs to be installed locally -- one of the reasons for this is that it allows each project to have different versions of the same module installed. Commented Aug 4, 2013 at 23:37
  • 2
    But shouldn't globally installed modules be able to be required globally, i.e. from any project/place? I think that prioritizing locally installed modules should be enough to let projects have different versions of the same module. Commented Oct 1, 2015 at 13:20
  • You want them locally installed because then other people will get the exact same version as you have. When you save the dependency in your package.json, someone else can install your project via "npm install" and get the exact same versions of your packages. If you install something globally you just can have 1 version (normally the latest) but this dependency would not get shared across other team members and thus will be missing. Commented Dec 2, 2016 at 10:29

5 Answers 5

15

I was face same problem but if you want to install browserify module you can use this

 npm install browserify 
Sign up to request clarification or add additional context in comments.

Comments

2

i have to find another way for install browserify for globally so you can use this command for linux

sudo npm install browserify -g 

Comments

2

Try:

npm install js-base64 

and if you encounter the below error

npm ERR! Error: EACCES: permission denied, unlink '/Users/host/module/node_modules/npm/node_modules/.bin/node-gyp' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, unlink '/Users/host/module/node_modules/npm/node_modules/.bin/node-gyp'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'unlink', npm ERR! path: '/Users/host/module/node_modules/npm/node_modules/.bin/node-gyp' } npm ERR! npm ERR! Please try running this command again as root/Administrator. 

then use the below command:

sudo npm install -g js-base64 --save 

Comments

0

I encountered this issue in an Angular 11 project and installing browserify didn't solve my issue but installing os-browserify did.

npm install os-browserify 

Comments

0

I encountered this issue. I have deleted all the browserify modules from node modules and again tried:

npm install browserify 

And now it's working. You can try this.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.