Create React App Custom Templates “cannot find module `cra-template-[template-name]`”

After creating a Create React App custom template and trying to create a project from it locally (npx create-react-app cratest --template file:./cra-template-[template-name]), Create React App failed with a cannot find module error:

cannot find module cra-template-[template-name]

Rather than copy/pasting the package.json from the docs, I’d created my package.json with npm init which by default sets the value of the main property to index.js.

Changing main to template.json, as it is in the Create React App docs was the fix.

More for self reference than anything else.

Did you like this post? Why not subscribe?

Leave a Reply

Your email address will not be published. Required fields are marked *