Skip to content

Custom template cannot be created from local path #8893

Closed
@emoriarty

Description

@emoriarty

Describe the bug

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.

Which terms did you search for in User Guide?

I followed the official doc on this matter.

Environment

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:

npx create-react-app your-app --template file:../cra-template-myapp

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions