I'm currently using browser-sync as a gulp dev-dependency for an express.js app.
Everything seems to work fine in a local version of this app but when I:
git clone the reponpm install npm start or nodemon ./bin/wwwgulpRunning gulp will give me an error that looks related to browser-sync and immutable.
Here's a truncated error (full errors near the end of the issue):
throw err;
^
Error: Cannot find module 'immutable'
...
(truncated for length)
...
When I look at the output from install browser-sync by itself, I can see that immutable is installing successfully:
$ npm install browser-sync --save-dev
...
CXX(target)
Release/obj.target/bufferutil/src/bufferutil.o
[email protected] node_modules/browser-sync
...
โโโ [email protected]
...
node_modules and re-installing all dependencies with npm install but the error still persists.package.json, tried removing ^ and ~ from dependencies to lock-in versions for npm modules$ npm install browser-sync --save-dev
npm WARN package.json [email protected] No repository field.
> [email protected] install /Users/brianhan/Dev/sites/brianhan-io-restart/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
> [email protected] install /Users/brianhan/Dev/sites/brianhan-io-restart/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
[email protected] node_modules/browser-sync
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected] ([email protected])
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected])
โโโ [email protected] ([email protected], [email protected], [email protected])
โโโ [email protected] ([email protected])
โโโ [email protected] ([email protected])
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected])
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected])
โโโ [email protected] ([email protected])
โโโ [email protected] ([email protected], [email protected])
โโโ [email protected] ([email protected], [email protected], [email protected])
โโโ [email protected]
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
$ gulp
throw err;
^
Error: Cannot find module 'immutable'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/brianhan/Dev/sites/brianhan-io-restart/node_modules/browser-sync/lib/hooks.js:4:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Happening to me as well, same stack trace.
I don't know if this will help, since I am running BrowserSync from the command line in Terminal instead of via Gulp, but this is what I needed to do to fix the "Cannot find module 'immutable'" error message on my system.
I needed to install the "immutable" Node.js module globally using the following command with the "-g" flag so I didn't get an error telling me it cannot find the module:
npm install -g immutable
I also installed BrowserSync by executing the following command to install it globally:
npm install -g browser-sync
I installed it globally for now, but may install it locally under each project in the future.
This is probably not related, but I also changed the ownership of Node.js files so when installing modules I don't have to use "sudo" everytime using the following command:
sudo chown -R whoami /usr/local/lib/node_modules
More details about this are available at http://mawaha.com/permission-fix-node-js/ and https://docs.npmjs.com/getting-started/fixing-npm-permissions
They tell you to change ownership of the full "/usr/local" directory in the npmjs.com documentation, but I didn't want to do that, so I used the command above following the mawaha.com guide.
Lastly, I read that you may need to add "/usr/local/lib/node_modules/:" to your $PATH variable in the .bash_profile or .profile files by editing it and adding the following line:
export PATH=/usr/local/lib/node_modules/:$PATH
I tried this when having problems, but ended up removing it, since installing immutable globally I think resolved the problem. My PATH statement now looks like the following in my .bash_profile file under my home directory in OS X:
export PATH=/usr/local/bin:/usr/local/git/bin:$PATH
I have the PATH set this way so I can use the Homebrew version of Ruby and latest version of Git to load instead of the ones that come with OS X.
I hope this helps, but once again I am not trying to use BrowserSync via Gulp, so none of the above may apply.
export PATH=/usr/local/bin:/usr/local/git/bin:/usr/local/lib/node_modules/:$PATH
this same error is happening to me on this version, no problems in 2.2.1
npm rm browser-sync && npm install browser-sync
The problem was with the immutable lib, which is now fixed.
On Sun, 8 Mar 2015 at 06:17, William Huang [email protected] wrote:
this same error is happening to me on this version, no problems in 2.2.1
โ
Reply to this email directly or view it on GitHub
https://github.com/BrowserSync/browser-sync/issues/502#issuecomment-77735341
.
thanks @shakyShane!
@shakyShane What was the problem with the Immutable lib? I'm seeing a similar error in a continuous integration environment (not using Browser Sync), but my build works just fine locally.
The immutable lib published a broken version. You should reinstall to fix
I'm using Immutable 3.7.1. Looks like you were on 3.6.3. Is that right?
3.6.3 was the broken release, so we bumbed
I have problem with run node js
Start at Fri Dec 04 2015
module.js:339
throw err;
^
Error: Cannot find module 'http-sync'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
Most helpful comment
npm rm browser-sync && npm install browser-sync
The problem was with the immutable lib, which is now fixed.
On Sun, 8 Mar 2015 at 06:17, William Huang [email protected] wrote: