Included library "marked" showing "ReferenceError" on production only?

I need some help as to why an included library, would not be referenced in production but is in development.

Below is what I’m seeing. Note the ReferenceError: marked is not defined. This is only applicable on the production environment, the same code running on development, does not fail (hence the green ticks).

I’ve previously added the library of marked (and this was working up until the 1st February):

image

But when referencing it in a loop lambda, it says it’s not defined?

We’ve tried removing, deploying, adding back, deploying. No dice.

At a loss as to what can fix this and feels it’s inside ReTool rather than our implementation - feel blind to it!

Hi Matt,

Can you check in your setup scripts (click the cog on the left sidebar, then "JavaScript Configuration") and see if there is a line of code that requires marked in your production environment? If you don't see it, can you either add the line there or add a require line to your loop block to require marked? Please let me know if any of these options work for you.

Hey Colin,

I don't see any require statement, but I use moment.js with no issue and haven't required it anywhere?

I can add that though, but unsure what the correct statement is. Is it setting a const for marked?

const marked = require('marked');
or
const marked = require('insert url here');

Or are you saying just a plane require command in that config?

require('marked');

I tried all of the above including pulling marked from a CDN and no dice. Appreciate your help.

Cheers,
Mat

Hi Mat,

You should be able to const marked = require('marked'); in your code or in setup scripts to require the marked library. All libraries you specify in your libraries list should be available to be required in code blocks.

Does it work if you use the marked library in a new separate JS code block?
Can you make a new JS code block with the following and let me know the output in Logs?

const marked = require('marked'); console.log(marked);

Thanks,
Colin

1 Like

Hi @Mat_Camp, did requiring the library fix it, or are we still having this issue?

Hey @Paulo sorry for not coming back. I couldn't get it to play nicely, so ended up shifting to a different library which did work.

Now using markdown-it 14.0.0

Then in JavaScript configuration including:

const markdownit = require('markdown-it');

And within a loop in the workflow I'm simply calling:

markdownit().render(markdown)

Working as expected. I had followed similar require and inclusion steps for marked but couldn't get it to play nice so cut my losses and moved to an alternative package.

1 Like

Thank you for the update! :slightly_smiling_face: