create-react-app 自定义React模板抛出错误,找不到模块,

yduiuuwa  于 6个月前  发布在  React
关注(0)|答案(2)|浏览(72)

#12609 中讨论

原帖由 tylerssn 于2022年7月23日发布
尝试创建自定义模板时遇到错误,测试时出现问题

$ create-react-app --version
5.0.1
$ create-react-app temporary --template file:../../cra-template-mine
...
Error: Cannot find module 'file:/Users/me/Code//package.json'
Require stack:
- /Users/me/Code/@platform/create-react-app-platformsh/deleteme/node_modules/react-scripts/scripts/init.js
- /Users/me/Code/@platform/create-react-app-platformsh/deleteme/[eval]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.resolve (internal/modules/cjs/helpers.js:99:19)
    at module.exports (/Users/me/Code/@platform/create-react-app-platformsh/deleteme/node_modules/react-scripts/scripts/init.js:117:13)
    at [eval]:3:14
    at Script.runInThisContext (vm.js:134:12)
    at Object.runInThisContext (vm.js:310:38)
    at internal/process/execution.js:81:19
    at [eval]-wrapper:6:22
    at evalScript (internal/process/execution.js:80:60)
    at internal/main/eval_string.js:27:3 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/me/Code/@platform/create-react-app-platformsh/deleteme/node_modules/react-scripts/scripts/init.js',
    '/Users/me/Code/@platform/create-react-app-platformsh/deleteme/[eval]'
  ]
}

Aborting installation.
  node  has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Done.
```</div>
ergxz8rk

ergxz8rk1#

这是由于文件路径中存在@导致的。
我通常使用@Company、@organization等命名空间目录。

相关问题