question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browserify doesn't use project's `node_modules` directory when using symlink

See original GitHub issue

I 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:open
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
tomwidmercommented, Nov 17, 2015

My solution was to build using an npm script like:

"build:js": "NODE_PATH=./node_modules browserify ..."

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=.

1reaction
cvlmtgcommented, Aug 24, 2015

this should fix the problem, i.e. symlink react inside foo to the react that is inside your main app

app
  node_modules
    foo -> ../../foo
    react

foo
  node_modules
    react -> ../../app/node_modules/react
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found