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.

.jsx extensions not working after upgrade

See original GitHub issue

I recently upgraded Browserify from v10.2.4 to v12.0.1 and Babelify from v6.1.2 to v7.2.0

After the upgrade, when I run my build process I keep getting errors along the lines of:

[14:33:08] Error: Cannot find module './About' from '/Users/mherbst/Repos/data-validation-tool/src/client/components'
    at /Users/mherbst/Repos/data-validation-tool/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
    at load (/Users/mherbst/Repos/data-validation-tool/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/mherbst/Repos/data-validation-tool/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at /Users/mherbst/Repos/data-validation-tool/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:95:15)

My file structure looks like:

Example src/client/components/About.jsx

module.exports = React.createClass({...});

Example src/client/components/index.js

module.exports = {
  About: require('./About')
};

Example src/client/main.js

import {About, ...} from 'components';
...
...
...

This setup worked with the old version of Browserify. It breaks after the upgrade. Here is part of my build (Gulp pipeline): Part of src/gulpfile.js

var bundler = browserify({
  entries: ['client/main.js'],
  options: {
    debug: true,
    extensions: ['.jsx']
  },
  cache: {},
  packageCache: {}
});

bundler.transform(babelify, { presets: ["es2015", "react"] });

When I change Example src/client/components/index.js to

module.exports = {
  About: require('./About.jsx')
};

it works, which is what makes me think it’s a bug maybe. Is it, or did I miss something?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jmmcommented, Nov 10, 2015

You overwrote extensions with [".jsx"]. You need .js in there too.

0reactions
jmmcommented, Nov 11, 2015

@MatthewHerbst Ok, great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why .js [file Extension] is not added while importing a ...
For my case, I used a community template for create-react-app called typescript-empty . For some reason, they neglected to keep in the ...
Read more >
After updating to 1.4.0 the react-native extension no longer ...
Any idea if it is something to do with our extension that we can fix, or is updating to the insiders build the...
Read more >
eslint-plugin-react - npm
Start using eslint-plugin-react in your project by running `npm i eslint-plugin-react`. ... Automatically fixable by the --fix CLI option.
Read more >
Introducing JSX - React
It is called JSX, and it is a syntax extension to JavaScript. We recommend using it with React to describe what the UI...
Read more >
Tutorial: Create a Node.js and React app in Visual Studio
Learn how to create a Node.js web application project from a Visual Studio template.
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