Error: Cannot find module './submit-analytics' on now.sh


#1

Hello,

I wanted to use now.sh (zeit.co) to host my realm-js backend. I’ve tried to node and node-server build types and I always get the same error as soon as I require realm in my code.
Here is the error :

Error while initializing entrypoint: { Error: Cannot find module './submit-analytics'
    at webpackEmptyContext (/var/task/user/index.js:13014:10)
    at nodeRequire (/var/task/user/index.js:17382:36)
    at Object.762 (/var/task/user/index.js:17453:9)
    at __webpack_require__ (/var/task/user/index.js:22:30)
    at Object.332 (/var/task/user/index.js:6593:15)
    at __webpack_require__ (/var/task/user/index.js:22:30)
    at Object.82 (/var/task/user/index.js:19008:22)
    at __webpack_require__ (/var/task/user/index.js:22:30)
    at module.exports.100.PARAM_REGEXP (/var/task/user/index.js:37:18)
    at Object.<anonymous> (/var/task/user/index.js:40:10) code: 'MODULE_NOT_FOUND' }

The code works well locally with node 10.
Is there anything I can do on the realm side or is it an issue with now.sh environment ?
Thanks


#2

@mbritto I am not sure about now.sh’s environment but I do know we have run into complications on other serverless platforms - relating to the filesystem or node/OS environment the code is executed in. Also please note that when you open a realm you are downloading the realm file to local disk - which takes up time and puts un-necessary load on your ROS because every time you trigger the function you are re-downloading the same data.

You can disable analytics if you wish by setting:

// Don’t report Realm JS analytics data
// @see https://github.com/realm/realm-js/blob/master/lib/submit-analytics.js#L28

process.env.REALM_DISABLE_ANALYTICS = 'true';