Browserify doesn't use project's `node_modules` directory when using symlink
See original GitHub issueI have a shared module called foo
that I include in my project’s node_modules directory via npm link. In the foo
module, I have a require('react')
statement where ‘react’ is included as a peer dependency in my project’s node_modules. When using Browserify 9.0.8 everything works fine, but upgrading to 11.0.0 I get the error Cannot find module 'react'
.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Browserify not accessing node_modules - Stack Overflow
It doesn't seem like browserify is using 'node_modules' directory when using symlink.
Read more >API - esbuild
To join a set of files together with esbuild, import them all into a single entry point file and bundle just that one...
Read more >browserify-handbook - npm
Start using browserify-handbook in your project by running `npm i ... you can do is to symlink your app root directory into your...
Read more >Untitled
isDirectory - function to asynchronously test whether a directory exists * opts.realpath - function to asynchronously resolve a potential symlink to its ...
Read more >rollup.js
When this file contains imports, Rollup will try to resolve them relative to the current working directory. When using a config file, Rollup...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My solution was to build using an npm script like:
which means that the react module (and any other peer dependencies) from your app is found when requires (or ES6 imports) happen in the npm linked module(s). Probably doesn’t work on Windows, but adding a ‘set’ or something would probably fix it. It’s a hack, and you should check things do still work when you copy in the module to the node_modules and don’t use
NODE_PATH=
.this should fix the problem, i.e. symlink react inside foo to the react that is inside your main app