You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a new react-app with a custom local template fails because cannot find the provided module.
Error: Cannot find module 'cra-template-myapp'
Require stack:
- /Users/enrique/Workspace/test-cra/your-app/node_modules/react-scripts/scripts/init.js
- /Users/enrique/Workspace/test-cra/your-app/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
at Function.resolve (internal/modules/cjs/helpers.js:78:19)
at module.exports (/Users/enrique/Workspace/test-cra/your-app/node_modules/react-scripts/scripts/init.js:110:13)
at [eval]:3:14
at Script.runInThisContext (vm.js:131:20)
at Object.runInThisContext (vm.js:297:38)
at Object.<anonymous> ([eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at evalScript (internal/process/execution.js:94:25)
at internal/main/eval_string.js:23:3 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/enrique/Workspace/test-cra/your-app/node_modules/react-scripts/scripts/init.js',
'/Users/enrique/Workspace/test-cra/your-app/[eval]'
]
}
I also cloned the create-react-app repo to install from local the cra-template-typescript and the same error happens.
Environment Info:
current version of create-react-app: 3.4.1
running from /Users/enrique/.npm/_npx/65740/lib/node_modules/create-react-app
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
Binaries:
Node: 13.11.0 - ~/.nodenv/versions/13.11.0/bin/node
Yarn: Not Found
npm: 6.13.7 - ~/.nodenv/versions/13.11.0/bin/npm
Browsers:
Chrome: 81.0.4044.122
Firefox: 75.0
Safari: 13.1
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
After creating the cra-template-myapp folder, I run the next command as the docs says:
Ok. False alarm. I figured it out what's the issue.
The package.json should explicitly declare the main property pointing to the template.json file. I found it by looking at the cra-template-redux repo. I was looking at first at cra-template-typescript and did not include the main prop. My bad.
Anyway, I know that I had forgotten that node packages should export the main entry file but I think it should be great (and helpful) including this small detail in the official guide.
UPDATE: I leave here the PR updating the doc as I mentioned in the previous paragraph. Hope it helps.
Describe the bug
When creating a new react-app with a custom local template fails because cannot find the provided module.
I also cloned the
create-react-app
repo to install from local thecra-template-typescript
and the same error happens.Which terms did you search for in User Guide?
I followed the official doc on this matter.
Environment
Steps to reproduce
After creating the cra-template-myapp folder, I run the next command as the docs says:
Expected behavior
The new react app can be created from a local template.
Actual behavior
create-react-app crashes when a custom template installed locally is passed to
--template
parameter.The text was updated successfully, but these errors were encountered: