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.

An error is reported due to a specific CSS:opts.node.rangeBy is not a function

See original GitHub issue

What steps are needed to reproduce the bug?

When the code written with SCSS file contains font family, an error will be reported. as follows

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

The error information is as follows:

$ stylelint **/*.scss
TypeError: opts.node.rangeBy is not a function
    at new Warning (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/node_modules/postcss/lib/warning.js:9:29)
    at Result.warn (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/node_modules/postcss/lib/result.js:26:19)
    at report (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/utils/report.js:103:9)
    at complain (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:80:4)
    at checkNewline (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:187:11)
    at /Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:73:4
    at handleMatch (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/style-search/index.js:201:5)
    at module.exports (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/style-search/index.js:189:5)
    at /Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:72:3
    at /Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/lintPostcssResult.js:112:8
error Command failed with exit code 1.

What Stylelint configuration is needed to reproduce the bug?

{
  "extends": "stylelint-config-standard-scss",
  "overrides": [
    {
      "files": "**/*.scss",
      "rules": {
        "no-empty-source": null,
        "selector-list-comma-newline-after": null
      }
    }
  ]
}

How did you run Stylelint?

npx stylelint **/*.scss

Which version of Stylelint are you using?

14.0.1

What did you expect to happen?

No error reported

What actually happened?

$ stylelint **/*.scss
TypeError: opts.node.rangeBy is not a function
    at new Warning (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/node_modules/postcss/lib/warning.js:9:29)
    at Result.warn (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/node_modules/postcss/lib/result.js:26:19)
    at report (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/utils/report.js:103:9)
    at complain (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:80:4)
    at checkNewline (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:187:11)
    at /Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:73:4
    at handleMatch (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/style-search/index.js:201:5)
    at module.exports (/Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/style-search/index.js:189:5)
    at /Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/rules/max-line-length/index.js:72:3
    at /Users/ranhe/servyou/dpl-pro-javascript-template/node_modules/stylelint/lib/lintPostcssResult.js:112:8
error Command failed with exit code 1.

Does the bug relate to non-standard syntax?

SCSS

Proposal to fix the bug

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
hewenguangcommented, Dec 2, 2021

There are multiple postcss versions in the project. Among them, the postcss that stylelint depends on is the latest version, and the versions since other libraries in the project are lower versions, resulting in node_ Modules contains multiple postcss codes

1reaction
AntonyF-Andreanicommented, Feb 9, 2022

In my case following the steps fixed the problem (as suggested by @hewenguang ).

  • npm ls postcss (that show me multiple versions of postcss)
  • npm i postcss@8.2.15 (and install one in specific)
Read more comments on GitHub >

github_iconTop Results From Across the Web

opts.node.rangeBy is not a function" with PostCSS 8.4.4 ...
I expect stylelint to show list of errors. What actually happened? TypeError: opts.node.rangeBy is not a function at new Warning (node_modules/ ...
Read more >
Migrating to 14.0.0 - Stylelint
It configures the built-in rules for SCSS, and includes the postcss-scss syntax and stylelint-scss plugin (a collection of rules specific to SCSS).
Read more >
opts.node.rangeBy is not a function" with PostCSS 8.4.4
Fix "TypeError: opts.node.rangeBy is not a function" with PostCSS 8.4.4.
Read more >
PostCSS API
If you create a node manually (e.g., with postcss.decl() ), that node will not have a source property and will be absent from...
Read more >
NodeJs : TypeError: require(...) is not a function - Stack Overflow
For me, when I do Immediately invoked function, I need to put ; at the end of require() . Error: const fs =...
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