webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
6.97k stars 173 forks source link

 ELIFECYCLE  Command failed with exit code 1. #497

Closed deadcoder0904 closed 9 months ago

deadcoder0904 commented 9 months ago

I use knip in multiple projects for a week or maybe 2-3 weeks for now ever since I found it.

It is excellent but I somehow get this error replicated across different projects. Mainly used it in Next.js & Remix.

Probably have 3-4 projects that use knip & I have encountered this bug 5+ times now.

Just before exiting, it gives this error:

 ELIFECYCLE  Command failed with exit code 1.

Idk why or how?

I'm on Windows 11.

webpro commented 9 months ago

Sorry, but this description tells me close to nothing. Are you using Knip v4?

deadcoder0904 commented 9 months ago

yes.

"knip": "^4.3.1",

it tells me nothing either :)

deadcoder0904 commented 9 months ago

i mean i did try it on newly created next.js apps with pnpm create next-app multiple times. might be a windows related bug on powershell 7.

webpro commented 9 months ago

What's the output? Surely that single error message is not the only thing you see? Did you try --debug?

deadcoder0904 commented 9 months ago

Yes, I did try --debug.

Nope, its the only thing I see.

> knip "--debug"

[*] Unresolved configuration (from CLI arguments)
{
  cwd: 'E:/nextjs-rate-limit',
  tsConfigFile: undefined,
  gitignore: true,
  isProduction: false,
  isStrict: false,
  isShowProgress: false,
  isIncludeEntryExports: false,
  isIsolateWorkspaces: false,
  tags: [ [], [] ],
  isFix: false,
  fixTypes: []
}
[*] Parsed gitignore files
{
  gitignoreFiles: [ 'E:\\nextjs-rate-limit\\.gitignore' ],
  ignores: [
    '.git',
    '**/node_modules/**',
    '.yarn',
    '.git',
    '**/node_modules/**',
    '.yarn',
    'node_modules',
    'node_modules/**',
    '.pnp',
    '.pnp/**',
    '**/.pnp.js',
    '**/.pnp.js/**',
    '**/.yarn/install-state.gz',
    '**/.yarn/install-state.gz/**',
    'coverage',
    'coverage/**',
    '.next/',
    '.next/**',
    'out/',
    'out/**',
    'build',
    'build/**',
    '**/.DS_Store',
    '**/.DS_Store/**',
    '**/*.pem',
    '**/*.pem/**',
    '**/npm-debug.log*',
    '**/npm-debug.log*/**',
    '**/yarn-debug.log*',
    '**/yarn-debug.log*/**',
    '**/yarn-error.log*',
    '**/yarn-error.log*/**',
    '**/.env*.local',
    '**/.env*.local/**',
    '**/.vercel',
    '**/.vercel/**',
    '**/*.tsbuildinfo',
    '**/*.tsbuildinfo/**',
    '**/next-env.d.ts',
    '**/next-env.d.ts/**'
  ],
  unignores: []
}
[.] Glob options
{
  patterns: [],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  onlyDirectories: true,
  gitignore: true
}
[*] Included issue types
{
  files: true,
  dependencies: true,
  devDependencies: true,
  optionalPeerDependencies: true,
  unlisted: true,
  binaries: true,
  unresolved: true,
  exports: true,
  nsExports: true,
  types: true,
  nsTypes: true,
  enumMembers: true,
  classMembers: false,
  duplicates: true
}
[*] Included workspaces
[ 'nextjs-rate-limit' ]
[*] Included workspace configs
[
  {
    pkgName: 'nextjs-rate-limit',
    name: '.',
    config: {
      entry: [
        '{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts,js,mjs,cjs,jsx,ts,tsx,mts,cts}!',
        'src/{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts,js,mjs,cjs,jsx,ts,tsx,mts,cts}!'
      ],
      project: [
        '**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts,js,mjs,cjs,jsx,ts,tsx,mts,cts}!'
      ],
      paths: {},
      ignore: [],
      isIncludeEntryExports: false
    },
    ancestors: []
  }
]
[.] Enabled plugins
[ 'ESLint', 'Next.js', 'PostCSS', 'Tailwind', 'TypeScript' ]
[.] Definition paths (2)
[
  'E:/nextjs-rate-limit/declaration.d.ts',
  'E:/nextjs-rate-limit/next-env.d.ts'
]
[.] Entry paths in package.json (0)
[]
[.] Glob options
{
  patterns: [
    'eslint.config.js',
    '.eslintrc',
    '.eslintrc.{js,json,cjs}',
    '.eslintrc.{yml,yaml}',
    'package.json'
  ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: false,
  absolute: true
}
[.] ESLint config file paths (1)
[ 'E:/nextjs-rate-limit/.eslintrc.json' ]
[.] ESLint dependencies (1)
[ 'eslint-config-next' ]
[.] Next.js config file paths (0)
[]
[.] Next.js dependencies (17)
[
  'entry:next.config.{js,ts,cjs,mjs}',
  'production:app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
  'production:app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
  'production:app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
  'production:app/**/{route,default}.{js,ts}',
  'production:app/global-error.{js,jsx,ts,tsx}',
  'production:app/{manifest,sitemap,robots}.{js,ts}',
  'production:pages/**/*.{js,jsx,ts,tsx}',
  'production:src/app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
  'production:src/app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
  'production:src/app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
  'production:src/app/**/{route,default}.{js,ts}',
  'production:src/app/global-error.{js,jsx,ts,tsx}',
  'production:src/app/{manifest,sitemap,robots}.{js,ts}',
  'production:src/pages/**/*.{js,jsx,ts,tsx}',
  'production:src/{instrumentation,middleware}.{js,ts}',
  'production:{instrumentation,middleware}.{js,ts}'
]
[.] Glob options
{
  patterns: [ 'postcss.config.{cjs,js}', 'postcss.config.json', 'package.json' ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: false,
  absolute: true
}
[.] PostCSS config file paths (1)
[ 'E:/nextjs-rate-limit/postcss.config.js' ]
[.] PostCSS dependencies (2)
[ 'autoprefixer', 'tailwindcss' ]
[.] Glob options
{
  patterns: [ 'tsconfig.json', 'tsconfig.*.json' ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: false,
  absolute: true
}
[.] TypeScript config file paths (1)
[ 'E:/nextjs-rate-limit/tsconfig.json' ]
[.] TypeScript dependencies (1)
[ 'next' ]
[.] Glob options
{
  patterns: [
    'src/{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts}',
    '{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts}'
  ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: true,
  absolute: true,
  dot: true
}
[.] Entry paths (0)
[]
[.] Glob options
{
  patterns: [
    'src/pages/**/*.{js,jsx,ts,tsx}',
    'src/app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
    'src/app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
    'src/app/{manifest,sitemap,robots}.{js,ts}',
    'src/app/**/{route,default}.{js,ts}',
    'src/app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
    'src/app/global-error.{js,jsx,ts,tsx}',
    'src/{instrumentation,middleware}.{js,ts}',
    'pages/**/*.{js,jsx,ts,tsx}',
    'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
    'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
    'app/{manifest,sitemap,robots}.{js,ts}',
    'app/**/{route,default}.{js,ts}',
    'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
    'app/global-error.{js,jsx,ts,tsx}',
    '{instrumentation,middleware}.{js,ts}',
    '**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}',
    '!eslint.config.js',
    '!.eslintrc',
    '!.eslintrc.{js,json,cjs}',
    '!.eslintrc.{yml,yaml}',
    '!package.json',
    '!postcss.config.{cjs,js}',
    '!postcss.config.json',
    '!tailwind.config.{js,cjs,mjs,ts}',
    '!tsconfig.json',
    '!tsconfig.*.json'
  ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: true,
  absolute: true,
  dot: true
}
[.] Project paths (15)
[
  'E:/nextjs-rate-limit/declaration.d.ts',
  'E:/nextjs-rate-limit/next.config.mjs',
  'E:/nextjs-rate-limit/src/app/api/download/route.ts',
  'E:/nextjs-rate-limit/src/app/api/login/route.ts',
  'E:/nextjs-rate-limit/src/app/components/Download.tsx',
  'E:/nextjs-rate-limit/src/app/components/Fingerprint.tsx',
  'E:/nextjs-rate-limit/src/app/components/LoginForm.tsx',
  'E:/nextjs-rate-limit/src/app/layout.tsx',
  'E:/nextjs-rate-limit/src/app/lib/env.ts',
  'E:/nextjs-rate-limit/src/app/lib/rate-limit.ts',
  'E:/nextjs-rate-limit/src/app/lib/redis/client.ts',
  'E:/nextjs-rate-limit/src/app/lib/redis/ioredis.ts',
  'E:/nextjs-rate-limit/src/app/page.tsx',
  'E:/nextjs-rate-limit/src/app/store/zustand.ts',
  'E:/nextjs-rate-limit/src/automate-rate-limit/login.ts'
]
[.] Glob options
{
  patterns: [
    'src/pages/**/*.{js,jsx,ts,tsx}',
    'src/app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
    'src/app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
    'src/app/{manifest,sitemap,robots}.{js,ts}',
    'src/app/**/{route,default}.{js,ts}',
    'src/app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
    'src/app/global-error.{js,jsx,ts,tsx}',
    'src/{instrumentation,middleware}.{js,ts}',
    'pages/**/*.{js,jsx,ts,tsx}',
    'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
    'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
    'app/{manifest,sitemap,robots}.{js,ts}',
    'app/**/{route,default}.{js,ts}',
    'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
    'app/global-error.{js,jsx,ts,tsx}',
    '{instrumentation,middleware}.{js,ts}',
    'next.config.{js,ts,cjs,mjs}'
  ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: true,
  absolute: true,
  dot: true
}
[.] Plugin entry paths (5)
[
  'E:/nextjs-rate-limit/next.config.mjs',
  'E:/nextjs-rate-limit/src/app/api/download/route.ts',
  'E:/nextjs-rate-limit/src/app/api/login/route.ts',
  'E:/nextjs-rate-limit/src/app/layout.tsx',
  'E:/nextjs-rate-limit/src/app/page.tsx'
]
[.] Plugin project paths (0)
[]
[.] Glob options
{
  patterns: [
    'tsconfig.*.json',
    'tsconfig.json',
    'tailwind.config.{js,cjs,mjs,ts}',
    'postcss.config.json',
    'postcss.config.{cjs,js}',
    'package.json',
    '.eslintrc.{yml,yaml}',
    '.eslintrc.{js,json,cjs}',
    '.eslintrc',
    'eslint.config.js'
  ],
  cwd: 'E:/nextjs-rate-limit',
  dir: 'E:/nextjs-rate-limit',
  gitignore: true,
  absolute: true,
  dot: true
}
[.] Plugin configuration paths (5)
[
  'E:/nextjs-rate-limit/.eslintrc.json',
  'E:/nextjs-rate-limit/package.json',
  'E:/nextjs-rate-limit/postcss.config.js',
  'E:/nextjs-rate-limit/tailwind.config.ts',
  'E:/nextjs-rate-limit/tsconfig.json'
]
[*] Created 1 programs for 1 workspaces
[*] Analyzing used resolved files [P1/1] (18)
[
  'E:/nextjs-rate-limit/declaration.d.ts',
  'E:/nextjs-rate-limit/next-env.d.ts',
  'E:/nextjs-rate-limit/next.config.mjs',
  'E:/nextjs-rate-limit/postcss.config.js',
  'E:/nextjs-rate-limit/src/app/api/download/route.ts',
  'E:/nextjs-rate-limit/src/app/api/login/route.ts',
  'E:/nextjs-rate-limit/src/app/components/Download.tsx',
  'E:/nextjs-rate-limit/src/app/components/Fingerprint.tsx',
  'E:/nextjs-rate-limit/src/app/components/LoginForm.tsx',
  'E:/nextjs-rate-limit/src/app/layout.tsx',
  'E:/nextjs-rate-limit/src/app/lib/env.ts',
  'E:/nextjs-rate-limit/src/app/lib/rate-limit.ts',
  'E:/nextjs-rate-limit/src/app/lib/redis/client.ts',
  'E:/nextjs-rate-limit/src/app/lib/redis/ioredis.ts',
  'E:/nextjs-rate-limit/src/app/page.tsx',
  'E:/nextjs-rate-limit/src/app/store/zustand.ts',
  'E:/nextjs-rate-limit/src/automate-rate-limit/login.ts',
  'E:/nextjs-rate-limit/tailwind.config.ts'
]
[*] Deleting principal at E:/nextjs-rate-limit for nextjs-rate-limit
Unused exports (2)
rateLimiter          unknown   src/app/lib/rate-limit.ts:26:14
setRateLimitHeaders  function  src/app/lib/rate-limit.ts:33:23
 ELIFECYCLE  Command failed with exit code 1.
webpro commented 9 months ago
Unused exports (2)
rateLimiter          unknown   src/app/lib/rate-limit.ts:26:14
setRateLimitHeaders  function  src/app/lib/rate-limit.ts:33:23
 ELIFECYCLE  Command failed with exit code 1.

This is probably close to what you see without --debug. This is not a bug, but behaving as expected: https://knip.dev/reference/cli#exit-code

The ELIFECYCLE error is commonly seen when using npm so maybe you've used something like npm run knip or npx knip.

deadcoder0904 commented 9 months ago

nope, i'm using this script on all my projects:

"knip": "knip"

deadcoder0904 commented 9 months ago

oh, so its lint error.

i do think it should gracefully exit by default even after showing lint errors.

webpro commented 9 months ago

i do think it should gracefully exit by default even after showing lint errors.

It's very common to exit with a non-zero exit code to inform you there are issues, especially useful to make CI workflows/pipelines fail. Other tools like linters or test frameworks do the same.

You still have a few options, though:

deadcoder0904 commented 9 months ago

cool, thanks for the tool. super useful. i used to use https://www.npmjs.com/package/depcheck before but this feels like an improvement.

webpro commented 9 months ago

Thanks! Let me know if there's anything that's not an improvement, and I'll be happy to look into it.

codenimble commented 2 weeks ago

FWIW I get the same error on next.js / react / typescript projects.

webpro commented 5 days ago

Again, that's probably working as expected: https://github.com/webpro-nl/knip/issues/497#issuecomment-1935662541