Skip to content

Error: Cannot find module 'utils' when executing local transform #146

Open
@EliteUser

Description

@EliteUser

Hello, trying to use your codeshift-cli, but faced a problem.
I created an example of my codemode repo - https://stackblitz.com/edit/node-uhcfpx?file=index.ts

Here I have a src folder which contains all version transforms. Each has its own motions and so on. Also there is a utils folder with some functions I need across all transformations.

So I'm trying to execute local transform, but getting some errors:

  1. Trying to execute codeshift -t ./src/3.0.0/transform.ts ./tmp/foo.tsx - getting an Error: Cannot find module './src/3.0.0/transform.ts'. Looks like cli cannot find a transform file for some reason. Maybe I'm doing something wrong.
  2. Trying to execute codeshift ./tmp/foo.tsx - it says that "No transforms specified" but then it gives me a prompt where I can choose a transformation (3.0.0) and then it throws an Error: Cannot find module 'utils'. In my project I have a utils folder and I use it in my transformations, but for some reason cli can not resolve it.
  3. Tests with jest works fine, so looks like jest can successfully run my codemode with utils (run jest in console is ok)

Could you please help me to understand and find a problem?

Metadata

Metadata

Assignees

Labels

🪲 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions