Search code examples
reactjsnext.jsnpx

How to use Codemod(Next.js)? Invalid transform choice


I tried to apply codemod on my pages(index.js is inside).

 npx @next/codemod pages
npx: installed 440 in 15.252s
Invalid transform choice, pick one of:
- name-default-component
- withamp-to-config
- url-to-withrouter

Directory structure

node_modules
package.json
package-lock.json
pages

How to run codemod?


Solution

  • You need to specify a valid transform before your path.

    From Next.js codemod documentation:

    Usage

    npx @next/codemod <transform> <path>

    • transform - name of transform, see available transforms below.
    • path - files or directory to transform
    • --dry Do a dry-run, no code will be edited
    • --print Prints the changed output for comparison