How To Fix Error: Can’t walk dependency graph: Cannot find module from When Run Browserify

When I open a terminal and run the command browserify ./lib/test1.js -o build.js to bundle the file ./lib/test1.js and all it’s dependent js module files into the build.js file, I meet the error Can’t walk dependency graph: Cannot find module ‘core-js/modules/es.array.iterator.js’ from ‘. This article will tell you how to fix this error.

1. How To Fix Error: Can’t walk dependency graph: Cannot find module from When Run Browserify.

  1. Below is the detailed error message for this error.
    > browserify ./lib/test1.js -o build.js
    Error: Can't walk dependency graph: Cannot find module 'core-js/modules/es.array.iterator.js' from 'D:\Work\dev2qa.com-example-code\PythonExampleProject\html\browserify-example\lib\test1.js'
    required by D:\Work\dev2qa.com-example-code\PythonExampleProject\html\browserify-example\lib\test1.js
    at C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:146:35
    at processDirs (C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:299:39)
    at isdir (C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:306:32)
    at C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:34:69
    at FSReqCallback.oncomplete (node:fs:198:21)
  2. The above error message says it can not find the js module core-js/modules/es.array.iterator.js.
  3. Then I run the command npm show core-js and find that the module core-js exist in the npm repository.
  4. Run the command npm list core-js and find the core-js module is not installed on the current project.
  5. Then I run the command npm install core-js to install it in the current project.
  6. Run the command npm list core-js again to confirm that the module has been installed successfully.
  7. Now when I run the command browserify ./lib/test1.js -o build.js to bundle the source js files to one target js file again, the error will not exist anymore.

2. How To Fix Error: Can’t walk dependency graph: Cannot find module from When Run Browserify To Bundle Multiple JS Files Into One.

    1. I also meet this error when I run the command browserify ./lib/*.js -o build.js to bundle multiple js files in the lib folder into one.
    2. Below are the detailed error messages.
      PS D:\Work\dev2qa.com-example-code\PythonExampleProject\html\browserify-example> browserify ./lib/*.js -o build.js
      Error: Can't walk dependency graph: Cannot find module 'D:\Work\dev2qa.com-example-code\PythonExampleProject\html\browserify-example\lib\*.js' from 'D:\Work\dev2qa.com-example-code\PythonExampleProject\html\browserify-example\lib\_fake.js'
          required by D:\Work\dev2qa.com-example-code\PythonExampleProject\html\browserify-example\lib\_fake.js
          at C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:167:35
          at load (C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:186:43)
          at onex (C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:211:17)
          at C:\Users\zhaosong\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:24:69
          at FSReqCallback.oncomplete (node:fs:198:21)
    3. To fix this error, you need to add all the js files’ names in the browserify command one after one like below.
      > browserify ./lib/test1.js ./lib/test2.js -o build.js

1 thought on “How To Fix Error: Can’t walk dependency graph: Cannot find module from When Run Browserify”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.