NPM Modules using 'strict mode' not working in Meteor 1.3

I installed the ‘stats-lite’ package from npm, and did a import stats from stats-lite in a server-side file. (I also tried a ‘require’ statement).

After starting Meteor 1.3rc2, I get this…

=> Exited with code: 8
W20160320-21:34:50.141(-5)? (STDERR) debugger listening on port 57158
W20160320-21:34:50.562(-5)? (STDERR) 
W20160320-21:34:50.564(-5)? (STDERR) /Users/ericterpstra/Dev/coin/meteolendo/.meteor/local/build/programs/server/packages/modules.js:111
W20160320-21:34:50.564(-5)? (STDERR) const isNumber = require("isnumber")
W20160320-21:34:50.564(-5)? (STDERR) ^^^^^
W20160320-21:34:50.567(-5)? (STDERR) SyntaxError: Use of const in strict mode.
W20160320-21:34:50.567(-5)? (STDERR)     at /Users/ericterpstra/Dev/coin/meteolendo/.meteor/local/build/programs/server/boot.js:276:30
W20160320-21:34:50.567(-5)? (STDERR)     at Array.forEach (native)
W20160320-21:34:50.568(-5)? (STDERR)     at Function._.each._.forEach (/Users/ericterpstra/.meteor/packages/meteor-tool/.1.2.4-rc.2.n1qq35++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160320-21:34:50.568(-5)? (STDERR)     at /Users/ericterpstra/Dev/coin/meteolendo/.meteor/local/build/programs/server/boot.js:133:5

The stats-lite code: https://github.com/brycebaril/node-stats-lite/blob/master/stats.js

1 Like

The stats-lite npm package is using ECMA2015 features, and Meteor node.js version does not support const, let and other ECMA2015 features.

I’m pretty sure the ecmascript meteor smart package does nothing about npm packages.

If you look at the “engines” section on the package json you’ll see

  "engines": {
    "node": ">=2.0.0"
  },

This “>= 2.0.0” means that this code runs on io.js 2.x or 3.x and node.js 4.x, 5.x or higher, and all of them support const/let.

I don’t know if there is something that can be done to run this package on Meteor without manually transpiling it, so we’ll have to wait on another community member ideas.

Good luck.

Yeah, I was wondering if Meteor was transpiling imported npm modules or not. Looks like it’s not. I guess unless someone says otherwise, I can fork it, or wrap it in a Meteor package rather than use npm.

Does Meteor transpile wrapped npm packages (on smart packages)?

No, nor should it. As nice as this would be for us, it’s the npm package developer’s responsibility to support whatever targets he wants. It’s pretty common these days for npm packages to have a prepublish script that pipes everything through babel.

The good news is that upgrading Node is high on the priority list after 1.3 is released.

1 Like

So @eterps, you’ll have to fork it and patch it to use card, then use your fork on package.json
If possible, submit a PR with a transpiration prepublish step

Thanks for all the replies. I ended up forking. Looking forward to a future Meteor version with Node 4.2 (or higher!)