Error: 'moment' module not found?


#1

Hello, as of this morning, I’ve noticed that those of my notebooks that use the moment npm module, return this error message when run as an endpoint:

{
    "error": "initialization_error",
    "message": "Error: Cannot find module 'moment'"
}

Obviously, this worked fine before. moment is a popular module, it’s available for most if not all supported node versions, so I’m a bit at a loss why I’m getting this now. :thinking:

For reference this is the notebook in question: https://runkit.com/jfix/export-stats-updater

Any help appreciated! Thanks.

Edit: I should add that the endpoint logs only contain a message saying that the module could not be found.


#2

Hi jfix, we are looking into this, sorry for the issue!


#3

Hi jfix, can you confirm that it did in fact work on 10.5.0 in the past? I am seeing the message “missing bson” (not moment), and I’m thinking that maybe upon updating from 8 to 10, we haven’t built bson yet and that’s why its failing. But this would only be the case if it stopped working when you upgraded to 10 immediately, not if it temporarily worked on 10.


#4

Hi @tolmasky, no, I cannot, unfortunately(?), confirm this as I upgraded to 10.5.0 just today in a desperate attempt to try to make the code work again. And you are right, that the bson package appears ‘missing’ when attempting to execute the endpoint using this node version. My apologies for this omission!

When attempting to understand this earlier today, I looked at the logs for version 4.0.1 (the one that worked fine until now), and saw lines for missing moment and bson packages. Right now, I no longer see these errors, which I don’t know how to interpret… as I didn’t change my code.

When calling the endpoint now, I’m getting error messages about mongoose.openUri not being a function.

{
    "error": "runtime_error",
    "message": "TypeError: mongoose.openUri is not a function",
    "stack": [
        "TypeError: mongoose.openUri is not a function",
        "    at exports.endpoint (eval at <anonymous> (runkit-runtime:4319:25), <anonymous>:30:18)",
        "    at handleRequest (runkit-runtime:4356:26)",
        "    at Server.<anonymous> (runkit-runtime:4239:13)",
        "    at emitTwo (events.js:126:13)",
        "    at Server.emit (events.js:214:7)",
        "    at parserOnIncoming (_http_server.js:619:12)",
        "    at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)"
    ]
}

This is even more weird, I have to admit, because a) the code worked before, but also b) I didn’t seemed to find the documentation for openUri on the Mongoose website …

So, I rewrote the code to not use that function, but the documented connect() method. Now I’m getting this:

{
    "error": "unexpected_error",
    "message": "Something unexpected happened. Please contact support@runkit.com. Please provide the case number 21f0521a-b82d-4226-8782-bfeb7a5728a5"
}

Does this help you help me? :wink:

Thanks for taking the time! :smile:


#5

@tolmasky, please don’t spend time on this right now; it seems that there is a database connection problem for which you can’t do anything. I’ll have to see once I’ve fixed that problem whether I can go back to the original code … Thanks, and sorry for the hassle.


#6

Hi jfix,

No worries, but we certainly do want to figure out what’s going on, as this at least seems to have originated from a problem on our end if it was working before but not anymore. One thing if you have time, if you could just copy-paste the entirety of the code to a new document and see if this changes the errors/resolves anything, that would be great. The reason for this is that by pasting the code onto a new document, it will once again just resolve all the packages to “latest” and we can perhaps narrow down if this is a node 10 issue with the packages that were working on 8.

Thanks,

Francisco


#7

by ‘new document’ do you mean a new notebook, or via a text document on my computer to get rid of some rich text (for versioning)?


#8

Just a new notebook, and then manually copy/paste the packages in. Or, you can just clone the notebook, and comment out the packages, run, and uncomment them (having a run without the package “clears” the memory of the pinned version).


#9

Interesting thing to know, I always wondered how I could upgrade npm modules’ versions of an existing notebook.

https://runkit.com/jfix/5b579beccb14850012a76454

The error is still a problem with mongoose.openUri which was kind of documented here: http://mongoosejs.com/docs/4.x/docs/connections.html. Now the mongoose npm module is 5.2.5. and the doc doesn’t mention openUri anymore: http://mongoosejs.com/docs/connections.html