question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[flow] The parameter passed to require() must be a literal string

See original GitHub issue

With 0.4.4 version.

if (state.opts.plugins) {
  const pluginsVisitors = state.opts.plugins.map((pluginName) => {
    const plugin = require(pluginName);
    return plugin({ template, types }).visitor;
  });

  programPath.traverse(visitors.merge(pluginsVisitors));
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
oliviertassinaricommented, May 5, 2017

Regarding the why of this new lines of code, it can be summarized with that tweet.

I have been adding that line to the .flowconfig file. The best solution I could find.

[options]

module.ignore_non_literal_requires=true
3reactions
sanderskycommented, Jul 12, 2017

Worst case if you want to solve it in this repo you can add // $FlowFixMe above the line in question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The parameter passed to require() must be a literal string. #2946
I am having this problem, i assume caused by using a backtick string template in the webpack require function: 3: const Vue ...
Read more >
[flow] The parameter passed to require() must be a literal string
With 0.4.4 version. if (state.opts.plugins) { const pluginsVisitors = state.opts.plugins.map((pluginName) => { const plugin = require(pluginName); return ...
Read more >
require() must have a single string literal argument React Native
The solution there if you have more than 2 choices is to pass the result of the require as a parameter instead of...
Read more >
Variable reference in Switch Case parsed as string...
I have a very complex flow with 70 branches formed from nested switch ... Only a literal of type string or interger or...
Read more >
Handbook - Literal Types - TypeScript
Using literal types with TypeScript. ... and booleans; by using literal types you can allow an exact value which a string, number, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found