How can change script.js file into bundel.js file using browserify?

Viewed 379

I want to change my script.js file into bundel.js file using browserify:

browserify script.js > bundel.js

Here I got an error:

Error: Can't walk dependency graph: Cannot find module 'C:\Users\ASUS\nodescript.js' from 'C:\Users\ASUS_fake.js' required by C:\Users\ASUS_fake.js

2 Answers

I have had similar problem in the last 1 hour and came here but finding no answer went back to the basics and resolved the issue through:

  1. Uninstalling browserify globally to avoid aliases

    npm uninstall browserify -g

  2. Went to the project folder and installed browserify

    npm install browserify -g

This did the trick and I was good to go.

Another thing to look for is if the npm package you are trying to require is valid.

One time I incorrectly install moment by using npm i momentjs (this library doesn't exist) instead of npm i moment (the correct library). As a result , I got the same exact error.

Realizing my dumb mistake, I install the correct momentjs library and required it. After that it worked.

Related