Create-react-app: Failed to import mqtt module after upgrading react-scripts to 0.4.1

Created on 5 Sep 2016  路  23Comments  路  Source: facebook/create-react-app

I was using mqtt module with react-scripts v0.2.3 to build some sort of IoT web app. Everything was fine until I upgraded the react-scripts to v0.4.1. There was an error from the developer console:

Uncaught Error: process.binding is not supported from browser.js at line 173.

Removing the import mqtt from 'mqtt' or require('mqtt') solve the issue, but that's not what I wanted. Any help would be appreciated. Thanks in advance!

bug

Most helpful comment

All 23 comments

I can鈥檛 reproduce this on master.

I鈥檓 going to release 0.4.2 today.
If you still have issues with it, please provide a project reproducing it.

Ok then, I'll re-open this issue if I still have the same problem with 0.4.2. Thanks!

I still have the same issue with 0.4.2, here's the project repo: https://github.com/alwint3r/reweather. You can checkout to 0.4.2 branch on that repo to check the error, since the master branch uses 0.3.1 and everything works fine.

The file that causes the error is src/lib/mqttredux.js.

I can't reproduce this on the 0.4.2 branch of that repo.

I also can鈥檛 reproduce this on 0.6.0 branch of that repo.
If it doesn鈥檛 work, please delete node_modules and run npm install.
Maybe some dependency is stale for some reason.

Thanks!

I did remove the node_modules and reinstall the dependencies but nothing changed. I still see nothing on the screen but the same error on the browser console.

By the way, I am going to try another alternatives since mqtt module is not my only option.
Thank you for your effort on this awesome tool!

I had the same problems with npm@2. The problem disappears with npm@3.

@aronwoost I also have npm v3 installed. What version of node are you using?

I wonder if it's because I'm still using node v4.

node: v4.5.0
npm 3.10.6

Try clearing npm cache before running npm install again.

rm -rf node_modules
rm -rf ~/.npm
npm cache clear
npm install

@aronwoost mine is exactly the same as yours.
@gaearon I did clear the cache but nothing changed.

This is super weird.
Can you tell me more about this message:

Uncaught Error: process.binding is not supported from browser.js at line 173.

Does it have a stack trace?

Uncaught Error: process.binding is not supported
process.binding @ browser.js:173
(anonymous function) @ util.js:3
(anonymous function) @ util.js:938
(anonymous function) @ bundle.js:6889
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ stream.js:6
(anonymous function) @ bundle.js:7006
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ readable.js:1
(anonymous function) @ readable.js:13
(anonymous function) @ bundle.js:8887
__webpack_require__ @ bundle.js:556f
n @ bundle.js:87
(anonymous function) @ store.js:2
(anonymous function) @ store.js:110
(anonymous function) @ bundle.js:8878
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ client.js:7
(anonymous function) @ client.js:923
(anonymous function) @ bundle.js:8869
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ index.js:2
(anonymous function) @ index.js:139
(anonymous function) @ bundle.js:8860
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ mqttredux.js:13
(anonymous function) @ bundle.js:8851
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ index.js:31
(anonymous function) @ bundle.js:1363
__webpack_require__ @ bundle.js:556
fn @ bundle.js:87
(anonymous function) @ multi_main:3
(anonymous function) @ bundle.js:589
__webpack_require__ @ bundle.js:556
(anonymous function) @ bundle.js:579
(anonymous function) @ bundle.js:582

Here's line 172 - 174 in browser.js

process.binding = function (name) {
    throw new Error('process.binding is not supported');
};

I don't know where browser.js comes from. And as far as I know, mqtt is not built with C/C++ code.

The stacktrace points to a file where I included mqtt module with import { connect } from 'mqtt' on the first line in src/lib/mqttredux.js

Also last comment here: https://github.com/webpack/webpack/issues/798

But it all made no sense to me...

I noticed the same problem with my colleague, that uses Ubuntu, node 6.6.0 and npm 3.10.7. On windows this app runs without any problems.
He tried to run app and got this exact error (process.binding), but he discovered that the problem lied with this package: superagent-xml2jsparser, which uses xml2js. Once he removed it, the app runs now.
Apparently it needs browserify.

Oh yes, I'm also using ubuntu 14.04 with node v4.5.0 and npm 3.10.6.

Thank you for the hint @themre! I'll get back to this issue ASAP.

Hi! Sorry for late response. I can not find both superagent-xml2jsparser and xml2js. However I managed to solve the problem by running my app inside docker container. I still have no idea why the app does not work on my host machine. But I think I am happy with my current solution, so I'm gonna close this issue now. Thank you!

I'm having the same problem. Clean fresh create-react-app app and just import mqtt, I'm not even using it.
node - 6.9.1
npm - 3.10.8
create-react-app - 0.6.1
"mqtt": "^2.0.1",
XUbuntu 16.04

Great! I had no idea why this issue happens because there was no compile error. Thank you for your effort! You people are awesome!

Yea, sorry it was confusing.
Confused the hell out of us too, it took a month to get to the cause.

I didn't realize that there was no NODE_PATH inside the docker container. Now I know why it worked back then.

I'm glad that this issue is finally closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

fson picture fson  路  3Comments

wereHamster picture wereHamster  路  3Comments

oltsa picture oltsa  路  3Comments