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.

`no-cycle` breaks when my files import node_module `index.es.js` files from fortawesome

See original GitHub issue

This is a totally wacky one. The files throwing errors below are imported by two of my js files. And for some reason, they’re getting parsed, even though no other files in node_modules are. Of course, I’m in a monorepo, which might confound things a bit:

/@arc // root package
  /node_modules // actual modules hoisted to here
  /apps
    /react-app
      /components
        /Icon.js // importer

The import statements are nothing special:

import {library} from '@fortawesome/fontawesome-svg-core';
import {faFacebookF} from '@fortawesome/free-brands-svg-icons';
import {faCalendar} from '@fortawesome/free-regular-svg-icons';
import {faBook} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';

And these are the errors:

Error while parsing /Users/msc/Code/hub/@arc/node_modules/@fortawesome/fontawesome-svg-core/index.es.js
Line undefined, column undefined: Cannot read property 'tokens' of null
`parseForESLint` from parser `/Users/msc/Code/hub/@arc/node_modules/babel-eslint/lib/index.js` is invalid and will just be ignored

Error while parsing /Users/msc/Code/hub/@arc/node_modules/@fortawesome/free-brands-svg-icons/index.es.js
Line undefined, column undefined: Cannot read property 'tokens' of null
`parseForESLint` from parser `/Users/msc/Code/hub/@arc/node_modules/babel-eslint/lib/index.js` is invalid and will just be ignored

Error while parsing /Users/msc/Code/hub/@arc/node_modules/@fortawesome/free-regular-svg-icons/index.es.js
Line undefined, column undefined: Cannot read property 'tokens' of null
`parseForESLint` from parser `/Users/msc/Code/hub/@arc/node_modules/babel-eslint/lib/index.js` is invalid and will just be ignored

Error while parsing /Users/msc/Code/hub/@arc/node_modules/@fortawesome/free-solid-svg-icons/index.es.js
Line undefined, column undefined: Cannot read property 'tokens' of null
`parseForESLint` from parser `/Users/msc/Code/hub/@arc/node_modules/babel-eslint/lib/index.js` is invalid and will just be ignored

Error while parsing /Users/msc/Code/hub/@arc/node_modules/@fortawesome/react-fontawesome/index.es.js
Line undefined, column undefined: Cannot read property 'tokens' of null
`parseForESLint` from parser `/Users/msc/Code/hub/@arc/node_modules/babel-eslint/lib/index.js` is invalid and will just be ignored

The errors go away when I disable no-cycle. Thanks again for the help!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
robmadolecommented, Apr 9, 2020

Thanks @ljharb

0reactions
ljharbcommented, Apr 9, 2020

node’s official docs for .js vs .mjs, but no, there’s no official doc for “js files should always be transpiled on prepublish into CJS”, that’s just the overwhelming community convention for a decade.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`.es.js` should be renamed `.mjs` · Issue #16439 - GitHub
The fix is to rename the files .mjs which officially indicates they are modules, not common-js style exports. Expected behavior. I expect other ......
Read more >
Please how can I fix this error in my react app - Stack Overflow
Please post your package.json file so to be able to better determine the cause of the issue.
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
When a .ts file is compiled as an ES module, ECMAScript import / export syntax is left alone in the .js output; when...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Mandatory file extensions#. A file extension must be provided when using the import keyword to resolve relative or absolute specifiers. Directory indexes (e.g. ......
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