Load a "meteor add <package>" for only the client


#1

If I install a package with

meteor add <package>

how/where do I then tell meteor to only load that package for the client? (Or server.) While I have seen references to package.js, it’s not clear to me where I would park such a file in this case. Rather it seems to me that there must be some basic way of telling meteor to only include that package for the client, but I just seem to be missing how.

As a concrete example,

meteor add marineboudeau:headroom

When I start meteor, I get a somewhat expected error for the server owing to the lack of the “window” object,

W20160801-16:40:31.043(-4)? (STDERR) /Users/dnewman/.meteor/packages/meteor-tool/.1.4.0.1gm32bp++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20160801-16:40:31.044(-4)? (STDERR) 						throw(ex);
W20160801-16:40:31.044(-4)? (STDERR) 						^
W20160801-16:40:31.044(-4)? (STDERR) 
W20160801-16:40:31.044(-4)? (STDERR) ReferenceError: window is not defined
W20160801-16:40:31.044(-4)? (STDERR)     at packages/marineboudeau_headroom/packages/marineboudeau_headroom.js:15:1

Thanks


#2

BTW, I did just now work out two work-arounds/solutions

  1. download the package from github, put it under packages/, and provide a package.js file. Then add it with meteor add <local-package-name>.
  2. install with meteor npm --save, and put a package.js file down in the appropriate node_modules/<package-name>/ directory.

Now back to my load order issue whereby the package (headroom) seems to be being loaded before angular in the client…


#3

marineboudeau:headroom is not a meteor package. The package.json decides which code runs on server and which on client, you can not “add a package only to the client”.