I am upgrading my app to Meteor 1.3+ (finally). My app is using a lot of local Meteor packages in the folder /packages. I know how to install npm packages globally and reference them from Meteor packages via import
. But what if I want to define the npm dependencies in the Meteor package itself, so the Meteor package becomes independent of the app configuration? In the early days, you would use Npm.depends Does this still work in Meteor 1.3+? Putting the references in the global package.json doesn’t feel right, as it breaks the component architecture.
Npm.depends
works as it ever did.
Jupp, found out that it works. But it causes problems with the “normal” package.json and npm install.
Shouldn’t cause any problems. Package npm dependencies are managed separately within the package, and automatically installed by Meteor.
If you want to add them as peer dependencies, meaning you have to install them in the main app, use tmeasday:check-npm-versions
to alert package consumers that they must install an npm package
What seems to be the problem?
When I try to add new packages to the package.json, I got some error messages. But interestingly, these messages disappeared now. Dunno why.
Thanks for that tip, that’s actually a pretty smart solution.
BTW: I didn’t even know that for every Npm.depends()
a separate copy of the npm package would be shipped with my app.
I now tried out the check-npm-versions
package.
In principle, this works. However, for client-only packages, it outputs the error message in the client console only. This can be missed quite easily. It would be perfect if the server would log that problem, too.
I’m also uncertain if this package is really actively maintained. There are quite some unanswered issues there. After all my experiences with packages like that, I’m not sure if it is worth using it if it has been dropped.
It also seems to lack support for semver, so you have to state a specific version, otherwise you’ll get a warning.
I found this script a while back here. Also, here is the original author.
How to get list of npm packages including dependencies:
for p in `meteor list | grep '^[a-z]' | awk '{sub(/[+*]$/, "", $2); print $1"@"$2 }'`; do echo "$p"; meteor show "$p" | grep -E '^ [a-z]'; echo; done
I hope this helps somehow.
When I’m using check-npm-versions
I put it in a separate file and run it for both client and server.
It’s supposed to handle semver, and I use it regularly with version strings like: 1.x.x
or ^0.4.x
with no issue.
As for maintenance, I’m sure it could be improved, but it’s pretty simple, so I don’t think there’s any risk in using it.