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.

2.19.0: rules.map is not a function

See original GitHub issue

I’m using moo 0.5.0, with nearley 2.18.0. Upgrading to 0.5.1 and 2.19.0 respectively, then re-generating the parsers causes the following error:

TypeError: rules.map is not a function
at Function.Grammar.fromCompiled (/blah/blah/node_modules/nearley/lib/nearley.js:173:27)

The preceding call in the stack is const parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));, where the grammar is compiled with nearleyc grammar.ne -o src/grammar.ts.

I’m using node 10.17.0 with typescript 3.5.3. Have you come across this issue?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

6reactions
jonmintercommented, Mar 23, 2020

I was having this issue. Workaround when you’re importing your grammar do this:

import { default as myGrammar } from './my-grammar-module';
const myParser = new nearley.Parser(nearley.Grammar.fromCompiled(myGrammar));

Instead of:

import * myGrammar from './my-grammar-module';
const myParser = new nearley.Parser(nearley.Grammar.fromCompiled(myGrammar));

Unfortunately it seems this affects nearley-test as I get the same error message when trying to use the test CLI command.

0reactions
jonmintercommented, Mar 25, 2020

No problem, glad I can help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: rules.map is not a function - React js - Stack Overflow
selectedFormJSON.FORM_RULE is an object. You cannot use map on an object.
Read more >
TypeError: map() is not a function in React | bobbyhadz
The "TypeError: map is not a function" occurs when we call the map() method on a value that is not an array. To...
Read more >
2.19.7 Data-Mapping Attribute Rules, Clauses, and Directives
2.19.7 Data-Mapping Attribute Rules, Clauses, and Directives. This section describes how the data-mapping and data-sharing attributes of any variable ...
Read more >
google earth engine - mosaic.map is not a function
You can not map over a single image. After you calculated the median of your collection, you receive only one image and .map...
Read more >
aws-cdk-lib module - AWS Documentation
A Stack is the smallest physical unit of deployment, and maps directly onto a ... As a final note: Stack s are not...
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