AndreaPontrandolfo / sheriff

A comprehensive and opinionated Typescript-first ESLint configuration.
https://www.eslint-config-sheriff.dev
MIT License
111 stars 7 forks source link

npx command error #26

Closed cmdcolin closed 1 year ago

cmdcolin commented 1 year ago

I ran the npx command in a repo with no eslint configs, it produces an error

not sure if it's expected to error out, or unexpected but thought i'd let you know :)

using yarn v1

%  npx create-sheriff-config
Need to install the following packages:
  create-sheriff-config@2.9.1
Ok to proceed? (y)
verbose: ▪ 'eslint.config.js' file not found. Generating and configuring 'eslint.config.js' file...
warn:    ▪ ⚠️  If you have other Eslint configs in your project, remove them.
verbose: ┏ Setting Sheriff with options:
verbose: ┃ [1] {
verbose: ┃ [2]   react: false,
verbose: ┃ [3]   lodash: false,
verbose: ┃ [4]   next: false,
verbose: ┃ [5]   playwright: false,
verbose: ┃ [6]   jest: false,
verbose: ┃ [7]   vitest: false
verbose: ┗ [8] }
info:    ▪ ✔️  Successfully generated eslint.config.js file.
verbose: ▪ An already present 'prettier' configuration was found in the project. Skipping '.prettierrc.json' file generation and configuration.
verbose: ▪ No '.prettierignore' file was found in the project. Generating and configuring '.prettierignore' file...
verbose: ▪ Installing 'eslint'...
verbose: ▪ Installing 'eslint-define-config'...
verbose: ▪ Installing 'eslint-config-sheriff'...
silly:   ▪ Detected package manager: yarn
warning eslint-define-config@1.17.0: The engine "pnpm" appears to be invalid.
warning eslint-config-sheriff@11.4.0: The engine "pnpm" appears to be invalid.
warning "eslint-config-sheriff > eslint-plugin-etc@2.0.2" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc@5.2.0" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > @phenomnomnominal/tsquery@4.2.0" has incorrect peer dependency "typescript@^3 || ^4".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc > tsutils-etc@1.4.1" has incorrect peer dependency "typescript@^4.0.0".
error An unexpected error occurred: "could not find a copy of eslint to link in /home/cdiesh/4site_stuff/mailer_watcher/node_modules/eslint-config-sheriff/node_modules".
error:   ▪ ❌  Couldn't auto-install the required packages.
    You have to install them manually yourself.
    Please try to run: yarn add -D eslint@latest eslint-define-config@latest eslint-config-sheriff@latest. Error: Command failed: yarn add -D eslint@latest eslint-define-config@latest eslint-config-sheriff@latest
warning eslint-define-config@1.17.0: The engine "pnpm" appears to be invalid.
warning eslint-config-sheriff@11.4.0: The engine "pnpm" appears to be invalid.
warning "eslint-config-sheriff > eslint-plugin-etc@2.0.2" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc@5.2.0" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > @phenomnomnominal/tsquery@4.2.0" has incorrect peer dependency "typescript@^3 || ^4".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc > tsutils-etc@1.4.1" has incorrect peer dependency "typescript@^4.0.0".
error An unexpected error occurred: "could not find a copy of eslint to link in /home/cdiesh/4site_stuff/mailer_watcher/node_modules/eslint-config-sheriff/node_modules".

error:   ▪ ❌  Couldn't walk up the filesystem. Error: Error: Command failed: yarn add -D eslint@latest eslint-define-config@latest eslint-config-sheriff@latest
warning eslint-define-config@1.17.0: The engine "pnpm" appears to be invalid.
warning eslint-config-sheriff@11.4.0: The engine "pnpm" appears to be invalid.
warning "eslint-config-sheriff > eslint-plugin-etc@2.0.2" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc@5.2.0" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > @phenomnomnominal/tsquery@4.2.0" has incorrect peer dependency "typescript@^3 || ^4".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc > tsutils-etc@1.4.1" has incorrect peer dependency "typescript@^4.0.0".
error An unexpected error occurred: "could not find a copy of eslint to link in /home/cdiesh/4site_stuff/mailer_watcher/node_modules/eslint-config-sheriff/node_modules".

file:///home/cdiesh/.npm/_npx/1cf4107118993e1f/node_modules/create-sheriff-config/dist/index.js:84
  throw new Error(`${isString(error) ? error : String(error)}`);
        ^

Error: Error: Error: Command failed: yarn add -D eslint@latest eslint-define-config@latest eslint-config-sheriff@latest
warning eslint-define-config@1.17.0: The engine "pnpm" appears to be invalid.
warning eslint-config-sheriff@11.4.0: The engine "pnpm" appears to be invalid.
warning "eslint-config-sheriff > eslint-plugin-etc@2.0.2" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc@5.2.0" has incorrect peer dependency "typescript@^4.0.0".
warning "eslint-config-sheriff > eslint-plugin-etc > @phenomnomnominal/tsquery@4.2.0" has incorrect peer dependency "typescript@^3 || ^4".
warning "eslint-config-sheriff > eslint-plugin-etc > eslint-etc > tsutils-etc@1.4.1" has incorrect peer dependency "typescript@^4.0.0".
error An unexpected error occurred: "could not find a copy of eslint to link in /home/cdiesh/4site_stuff/mailer_watcher/node_modules/eslint-config-sheriff/node_modules".

    at printError (file:///home/cdiesh/.npm/_npx/1cf4107118993e1f/node_modules/create-sheriff-config/dist/index.js:84:9)
    at autoInstallPackages (file:///home/cdiesh/.npm/_npx/1cf4107118993e1f/node_modules/create-sheriff-config/dist/index.js:125:5)
    at async setDependencies (file:///home/cdiesh/.npm/_npx/1cf4107118993e1f/node_modules/create-sheriff-config/dist/index.js:144:3)
    at async main (file:///home/cdiesh/.npm/_npx/1cf4107118993e1f/node_modules/create-sheriff-config/dist/index.js:477:3)

Node.js v18.14.2
AndreaPontrandolfo commented 1 year ago

It's ok, i didn't expect to cover every possible usecase for every package manager in existence. I mainly support pnpm because that's what i use, so the experience with it should be smooth. I implemented the fallback that alerts you to install the dependencies yourself, in cases like this where the automatic installation fails. I think you can just copy/paste the command that the CLI suggests you and it should work. Or tweak it as you see fit.

cmdcolin commented 1 year ago

awesome, thanks for confirming!

AndreaPontrandolfo commented 1 year ago

@cmdcolin maybe the issue could be caused by having in pnpm in the engines field. See the message: The engine "pnpm" appears to be invalid.

I'll look into this this weekend.

I'll reopen this issue until i can confirm what the issue is.

AndreaPontrandolfo commented 1 year ago

@cmdcolin As i thought the issue was with the "engines: pnpm" field. It should now be fixed with this 4aba8c92a7efdde46a46ee09ca14cc070a9ee14d. Just update to the latest release and please let me know if it fixed it for you!