mattdesl / esmify

parse and handle import/export for browserify
MIT License
117 stars 8 forks source link

Error: Cannot find module 'browser-resolve' when running esmify #13

Closed isoaxe closed 3 years ago

isoaxe commented 3 years ago

Hey there,

I'm attempting to run Firebase authentication and need to esmify some of the node_modules that are written in ES6.

However, when I run the command I get the following error:

> browserify auth.js -p esmify > src/js/auth.js

internal/modules/cjs/loader.js:1017
  throw err;
  ^

Error: Cannot find module 'browser-resolve'
Require stack:
- /Users/myName/Desktop/Git/myApp/node_modules/esmify/resolve.js
- /Users/myName/Desktop/Git/myApp/node_modules/esmify/esmify.js
- /usr/local/lib/node_modules/browserify/index.js
- /usr/local/lib/node_modules/browserify/bin/args.js
- /usr/local/lib/node_modules/browserify/bin/cmd.js

So the esmify file resolve.js has a require('browser-resolve') statement at the top. I tried installing browser-resolve manually as a devDependency but just got a similar error, this time about @babel/preset-env. But surely these dependencies should be automatically installed?

Even when I do install the two modules named in the sequential errors, I still get the following:

> browserify auth.js -p esmify > src/js/auth.js

Error: [BABEL] /Users/myName/Desktop/Git/myApp/node_modules/firebaseui/dist/esm.js: @babel/helper-compilation-targets: 'modules' is not a valid target
- Did you mean 'node'? (While processing: "/Users/myName/Desktop/Git/myApp/node_modules/@babel/preset-env/lib/index.js") while parsing file: /Users/myName/Desktop/Git/myApp/node_modules/firebaseui/dist/esm.js

Any ideas on what I might be doing wrong here?

isoaxe commented 3 years ago

It turns out that the issue was being caused by a babel.config file that I had in place when attempting to resolve this issue via babel rather than esmify. Deleting the file resolved the issue.

jcubic commented 2 years ago

I have the same issue and I don't have any babel.config file. It seems that this is a dependency of esmify that needs to be installed. Which means that the library is broken by default.