browserify: Error: Cannot find module 'node_modules/is-buffer/index.js' from ...
$ cat buf.js
module.exports = function (b) { return Buffer.isBuffer(b) }
$ npm i browserify
...
$ ./node_modules/.bin/browserify buf.js
Error: Cannot find module 'node_modules/is-buffer/index.js' from '/home/kirill/tmp'
at /home/kirill/tmp/node_modules/resolve/lib/async.js:46:17
at process (/home/kirill/tmp/node_modules/resolve/lib/async.js:173:43)
at ondir (/home/kirill/tmp/node_modules/resolve/lib/async.js:188:17)
at load (/home/kirill/tmp/node_modules/resolve/lib/async.js:69:43)
at onex (/home/kirill/tmp/node_modules/resolve/lib/async.js:92:31)
at /home/kirill/tmp/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:82:15)
$ vim buf.js
$ cat buf.js
;(function () { new Buffer(0) })()
module.exports = function (b) { return Buffer.isBuffer(b) }
$ ./node_modules/.bin/browserify buf.js
(function e(t,n,r){function s(o, ... // ok
Related: https://github.com/substack/node-browserify/issues/1228
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 17 (2 by maintainers)
Links to this issue
Commits related to this issue
- ./-prefix relative paths in subdirectories Having a file in the same directory isn't the only situation in which the `require()` path needs to be prefixed with ./; it also happens when the target fil... — committed to browserify/insert-module-globals by goto-bus-stop 6 years ago
- ./-prefix relative paths in subdirectories (#71) * ./-prefix relative paths in subdirectories Having a file in the same directory isn't the only situation in which the `require()` path needs to b... — committed to browserify/insert-module-globals by goto-bus-stop 6 years ago
This should be fixed in insert-module-globals@7.0.2; do
npm updateto get it!Just do this =>
npm install is-buffer --saveI just met this issue today and it turned out that using an alternative npm (cnpm) to be the culprit. cnpm handles modules folder differently with symlinks for faster installations, but it screws up the dynamic module resolving.
I am putting this info here because of the potential vulnerability of browserify when modules are managed differently.
@Zeeech Don’t use cnpm.