babel: Modules depending on Babylon cannot be Browserified, failing with "Cannot find module './parser'" (T6930)

Issue originally made by Kawahara Eiji (syuilo)

Bug information

  • Babel version: 6.3.13
  • Node version: 5.3.0
  • npm version: 3.3.12

Options

I try to build my project, the following error occurs.

Error: Cannot find module './parser' from 'C:\Users\syuilo\Desktop\Misskey\Misskey-Web\node_modules\babylon'

Sorry my English. thanks.

Description

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 29

Most upvoted comments

Comment originally made by Jess Telford (jesstelford)

The workaround I’m using is npm shrinkwrap:

  1. Install all your deps
  2. Run npm shrinkwrap
  3. Edit npm-shrinkwrap.json so that you lock babylon to a working version (I found 6.3.26 to work). For example, by changing all instances of babylon requires to something like this:
    "babylon": {
      "version": "6.3.26",
      "from": "babylon@6.3.26",
      "resolved": "http://registry.npmjs.org/babylon/-/babylon-6.3.26.tgz"
    },
  1. Delete your node_modules folder
  2. npm install

Now you should have a locked version of babylon at 6.3.26 no matter how deep the dependency goes.

Note that you’re messing with the expected versions deep in your require tree - this could have unexpected consequences!