1

First time trying to use node module with meteor

installed:

meteor add meteorhacks:npm

then installed:

npm install multer

have a separate file in the server directory, called "loadMulter" with just this one line:

var multer = Meteor.npmRequire('multer');

now, running "meteor" and getting this error:

W20150609-12:22:56.528(-5)? (STDERR)          
W20150609-12:22:56.528(-5)? (STDERR) /home/eugene/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150609-12:22:56.529(-5)? (STDERR)                        throw(ex);
W20150609-12:22:56.529(-5)? (STDERR)                              ^
W20150609-12:22:56.531(-5)? (STDERR) ReferenceError: require is not defined
W20150609-12:22:56.531(-5)? (STDERR)     at app/node_modules/multer/node_modules/busboy/node_modules/dicer/node_modules/streamsearch/lib/sbmh.js:5:20
W20150609-12:22:56.531(-5)? (STDERR)     at app/node_modules/multer/node_modules/busboy/node_modules/dicer/node_modules/streamsearch/lib/sbmh.js:215:3
W20150609-12:22:56.531(-5)? (STDERR)     at /home/eugene/dev/meteor/socially/.meteor/local/build/programs/server/boot.js:222:10
W20150609-12:22:56.531(-5)? (STDERR)     at Array.forEach (native)
W20150609-12:22:56.532(-5)? (STDERR)     at Function._.each._.forEach (/home/eugene/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150609-12:22:56.532(-5)? (STDERR)     at /home/eugene/dev/meteor/socially/.meteor/local/build/programs/server/boot.js:117:5

What is the proper way to put these things together?

2 Answers 2

3

Don't install the npm package as a local node_module using npm install.

You need to specify the packages you want in a special file named package.json created after you add meteorhacks:npm and launch Meteor.

{
  "multer": "0.1.8"
}

https://github.com/meteorhacks/npm#defining-packages

Sign up to request clarification or add additional context in comments.

Comments

1

You cannot run npm install multer in Meteor app.

The correct way is:

  1. meteor add meteorhacks:npm
  2. Create file packages.json in top level directory with content:

    {
      "multer": "0.1.8"
    }
    
  3. Run meteor, the NPM package(s) will be installed automatically

  4. Include npm package using Meteor.npmRequire

Note: Be sure to delete node_modules folder created by previous npm install.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.