[Checkout Extensions] ERROR: Could not resolve modules

Solved

[Checkout Extensions] ERROR: Could not resolve modules

dbiggiogero
Shopify Partner
5 1 5

Hello,

I followed the steps written there: https://shopify.dev/docs/apps/getting-started/create

I generated an extension and got the `shopify.app.toml` updated.

When I launch `npm run dev`, the script crashes giving me those errors:

Error: Build failed with 2 errors:
    extensions/privacy-checkbox/src/Checkout.jsx:6:7: ERROR: Could not resolve "@shopify/ui-extensions-react/checkout"
    extensions/privacy-checkbox/src/Checkout.jsx:10:8: ERROR: Could not resolve "react/jsx-runtime"

Note that I didn't make any change to the code generated by `init @Shopify/app@latest` and `generate extension`.
I checked that the packages are installed and I see those 2 modules correctly installed.
Already tried to delete node_modules and package-lock.json, clean cache and update packages without success.

I'm also surprised that a vanilla extension is not working out of the box. What can I do?

Node: v20.10.0
npm: 10.40.0

Accepted Solution (1)

dbiggiogero
Shopify Partner
5 1 5

This is an accepted solution.

Seems like I got it working: there was a .pnp.cjs file on the root folder on my pc, totally outside the project folder, that somehow it's interfering with the build process of `shopify app dev`.

I deleted the file and the errors are gone.

View solution in original post

Replies 4 (4)

dbiggiogero
Shopify Partner
5 1 5

I also tried with pnpm, same procedure:

- create @Shopify/app,

- go into the generated folder

- pnpm generate extension
in all those steps I didn't encounter any error, I successfully linked my app to an existing one on my partner account.

but I get the same error on `pnpm dev`, same modules not found

dbiggiogero
Shopify Partner
5 1 5

used node 18.16.0 with npm 9.8.1 and got same errors

dbiggiogero
Shopify Partner
5 1 5

This is an accepted solution.

Seems like I got it working: there was a .pnp.cjs file on the root folder on my pc, totally outside the project folder, that somehow it's interfering with the build process of `shopify app dev`.

I deleted the file and the errors are gone.

jordanaf808
Shopify Partner
4 0 1

Stumbling across this thread totally solved my issue with a similar error with `@shopify/shopify_functions/run`! I renamed the `.pnp.cjs` file in my user folder and I was finally able to generate an extension *smh*. I tried almost every configuration of node, homebrew, npm, yarn, and macOS, but it was this file that was the culprit, now everything works fine. I only used Yarn on 1 project.