The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

9051 (2) [Avatar] Offline
#1
I see reference to demeteorizer in the MEAP. However, I'd like to use npm within my Meteor app. I've tried https://github.com/meteorhacks/npm, but I'm still getting errors like this one.


W20150322-11:50:00.764(-4)? (STDERR)
W20150322-11:50:00.767(-4)? (STDERR) /Users/lee/.meteor/packages/meteor-tool/.1.0.43.1izpa4h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150322-11:50:00.767(-4)? (STDERR) throw(ex);
W20150322-11:50:00.767(-4)? (STDERR) ^
W20150322-11:50:00.767(-4)? (STDERR) ReferenceError: module is not defined
W20150322-11:50:00.767(-4)? (STDERR) at app/node_modules/colors/lib/custom/trap.js:1:36
W20150322-11:50:00.767(-4)? (STDERR) at app/node_modules/colors/lib/custom/trap.js:47:3
W20150322-11:50:00.768(-4)? (STDERR) at /Users/lee/projects/sfh/.meteor/local/build/programs/server/boot.js:222:10
W20150322-11:50:00.768(-4)? (STDERR) at Array.forEach (native)
W20150322-11:50:00.768(-4)? (STDERR) at Function._.each._.forEach (/Users/lee/.meteor/packages/meteor-tool/.1.0.43.1izpa4h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150322-11:50:00.768(-4)? (STDERR) at /Users/lee/projects/sfh/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150322-11:50:04.707(-4)? (STDERR)
W20150322-11:50:04.708(-4)? (STDERR) /Users/lee/.meteor/packages/meteor-tool/.1.0.43.1izpa4h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150322-11:50:04.708(-4)? (STDERR) throw(ex);
W20150322-11:50:04.708(-4)? (STDERR) ^
W20150322-11:50:04.711(-4)? (STDERR) ReferenceError: module is not defined
W20150322-11:50:04.711(-4)? (STDERR) at app/node_modules/colors/lib/custom/trap.js:1:36
W20150322-11:50:04.711(-4)? (STDERR) at app/node_modules/colors/lib/custom/trap.js:47:3
W20150322-11:50:04.711(-4)? (STDERR) at /Users/lee/projects/sfh/.meteor/local/build/programs/server/boot.js:222:10
W20150322-11:50:04.711(-4)? (STDERR) at Array.forEach (native)
W20150322-11:50:04.712(-4)? (STDERR) at Function._.each._.forEach (/Users/lee/.meteor/packages/meteor-tool/.1.0.43.1izpa4h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150322-11:50:04.712(-4)? (STDERR) at /Users/lee/projects/sfh/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150322-11:50:08.159(-4)? (STDERR)
W20150322-11:50:08.159(-4)? (STDERR) /Users/lee/.meteor/packages/meteor-tool/.1.0.43.1izpa4h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150322-11:50:08.160(-4)? (STDERR) throw(ex);
W20150322-11:50:08.160(-4)? (STDERR) ^
W20150322-11:50:08.164(-4)? (STDERR) ReferenceError: module is not defined
W20150322-11:50:08.164(-4)? (STDERR) at app/node_modules/colors/lib/custom/trap.js:1:36
W20150322-11:50:08.165(-4)? (STDERR) at app/node_modules/colors/lib/custom/trap.js:47:3
W20150322-11:50:08.165(-4)? (STDERR) at /Users/lee/projects/sfh/.meteor/local/build/programs/server/boot.js:222:10
W20150322-11:50:08.165(-4)? (STDERR) at Array.forEach (native)
W20150322-11:50:08.165(-4)? (STDERR) at Function._.each._.forEach (/Users/lee/.meteor/packages/meteor-tool/.1.0.43.1izpa4h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150322-11:50:08.165(-4)? (STDERR) at /Users/lee/projects/sfh/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.



I would like to see Meteor in Action address using npm's in a Meteor app, rather than expecting demeteorizer to be used in all cases.

Thanks,
Lee
9051 (2) [Avatar] Offline
#2
For anyone else struggling with this, the solution is simple, but undocumented. You have to delete the node_modules directory from your Meteor project. The packages.json file is all you need, and node_modules will conflict with the copies that Meteor installs for itself.
stephan.hochhaus (92) [Avatar] Offline
#3
Section 9.3 explains how to use NPM with either meteorhacks:npm or creating a package.

There are basically two ways to add a NPM package to a project. The first is to wrap the NPM package into a Meteor package, which is usually the better approach. [...] The second approach is to use the meteorhacks:npm package that allows you to use a packages.json similar to plain Node.js projects.


I think we covered part of the topic you bring up already. Is the issue perhaps when using meteorhacks:npm with demeteorizer? I need to try this out, I have to admit.