Cannot statically analyse 'require(…, …)' in line 16

I am using nextjs.

When importing markdown-toc in nextjs I am getting the issue.

import toc from "markdown-toc";

Then I got the below error

Cannot statically analyse 'require(…, …)' in line 16

>Solution :

When going through the lib code:

'use strict';

 * Module dependencies

var diacritics = require('diacritics-map');
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;

 * Lazily required module dependencies

require('concat-stream', 'concat');

require gets overwritten by the library utils assignment (although it seems like a terrible idea).

I don’t know what bundler you use, but this is probably the source of the problem as it tries to evaluate the require with two parameters, which it cannot do.

I would log a Github ticket to use another identifier than require and fix the source of the problem.

Leave a Reply