Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module (after upgrading from 15.9.0 to 15.10.1) #7057

Closed
honzajavorek opened this issue Jul 7, 2023 · 5 comments
Closed

Comments

@honzajavorek
Copy link

What minimal example or steps are needed to reproduce the bug?

  1. Have a working stylelint configuration, e.g. as in https://github.com/honzajavorek/junior.guru/
  2. Have a dependabot suggest an upgrade to the latest version Bump stylelint from 15.9.0 to 15.10.1 juniorguru/junior.guru#1187
  3. See CI failed with the following error:
Error: Cannot find module 'stylelint/lib/utils/isRangeContextMediaFeature'
Require stack:
- /home/circleci/project/node_modules/stylelint-stylistic/dist/rules/media-feature-name-case/index.js
- /home/circleci/project/node_modules/stylelint-stylistic/dist/main.js
- /home/circleci/project/node_modules/stylelint/lib/augmentConfig.js
- /home/circleci/project/node_modules/stylelint/lib/createStylelint.js
- /home/circleci/project/node_modules/stylelint/lib/resolveConfig.js
- /home/circleci/project/node_modules/stylelint/lib/printConfig.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1047:15)
    at Module._load (node:internal/modules/cjs/loader:893:27)
    at Module.require (node:internal/modules/cjs/loader:1113:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/circleci/project/node_modules/stylelint-stylistic/dist/rules/media-feature-name-case/index.js:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1226:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)
    at Module.load (node:internal/modules/cjs/loader:1089:32)
    at Module._load (node:internal/modules/cjs/loader:930:12)
    at Module.require (node:internal/modules/cjs/loader:1113:19)
Aborted!

I tried to dig into the root cause, but honestly, I'm completely lost and confused about what could be the culprit. The only thing I know is that v15.9.0 works fine.

What minimal configuration is needed to reproduce the bug?

{
  "extends": "stylelint-config-twbs-bootstrap"
}

How did you run Stylelint?

subprocess.run(['npx', 'stylelint',
                'juniorguru/scss/**/*.*css',
                'juniorguru/image_templates/*.*css'], check=True)

Which Stylelint-related dependencies are you using?

{
  "stylelint": "15.9.0",
  "stylelint-config-twbs-bootstrap": "11.0.0"
}

What did you expect to happen?

To lint, as with v15.9.0.

What actually happened?

Stylelint crashes with a cryptic error.

Do you have a proposal to fix the bug?

If the issue is out of scope of Stylelint, at least the error could point me to the right places.

@TyIsI
Copy link

TyIsI commented Jul 7, 2023

Random other person who ran into this issue reporting in.

After searching for about an hour, I found it was removed in commit
8051822e502f75f62b812ad6cb83f613dbd5d843.

The root cause is in the stylelint-stylistic package.

Retiring the isRangeContextMediaFeature functionality would be expected to be mentioned as breaking functionality. So maybe a little learning moment for the stylelint team.

stylelint-stylistic maintainer is aware:
elirasza/stylelint-stylistic#12

@romainmenke
Copy link
Member

romainmenke commented Jul 7, 2023

Hi all,

I submitted the pull request that introduced this issue 👋
The function that was removed was an internal utility that, to the best of my knowledge, wasn't used by other packages. From my perspective this wasn't a breaking change.

Obviously this turned out to be incorrect.


Speaking strictly for myself and not representing anyone in this section :

I do want to say that this is not a learning moment for me.

I know that it can be annoying and frustrating when a tool you depend on suddenly throws errors.

Sometimes you just make a change that you think will be good for everyone and you get it wrong. This happens and this is fine.


The package using this function is intended as a replacement for deprecated rules.
So I am inclined to restore the utility, even if this utility isn't used internally any more.

Even more so because this package hasn't seen any activity in the last 2 months.
So I think restoring the utility is the quickest way to help affected users.

The utility can be removed again in v16.

@honzajavorek
Copy link
Author

honzajavorek commented Jul 7, 2023 via email

@ybiquitous
Copy link
Member

We've recently updated our document about the utilities with PR #7052:

## `stylelint.utils`
Stylelint exposes some useful utilities.
You're also welcome to copy any of the [internal utils](https://github.com/stylelint/stylelint/tree/main/lib/utils) into your plugin. You should not `require` or `import` them directly, as they are not part of the public API and may change or be removed without warning.

As possible, we don't want people to use internal utilities. Instead, we want them to use stylelint.utils since it's a public API.

We've been performing many refactorings, such as removing unused utilities and dependencies, to keep this project healthy. Restoring removed and unused them would worsen the project's maintainability. It'd become hard to determine whether we could remove such components.

Fortunately, elirasza/stylelint-stylistic#12 seems to be working. I'd like to wait for the new release of stylelint-stylistic if possible.

@honzajavorek
Copy link
Author

elirasza/stylelint-stylistic#12 is now resolved and new version released! The following has helped me to get a working stylelint installation:

npm uninstall stylelint-config-twbs-bootstrap 
npm install --dev stylelint-config-twbs-bootstrap

This upgrades stylelint-stylistic's version from 0.4.2 to 0.4.3 in the package-lock.json. Thanks everyone involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants