简体   繁体   English

发生 npx create-react-app 错误的事件

[英]The event in which npx create-react-app Error occurred

I keep getting errors when I do npx create-react-app .当我执行npx create-react-app时,我不断收到错误。 Please help me!!!!!!!!!!!!!请帮我!!!!!!!!!!!!! I tried yarn create react-app , but the result was the same.我尝试了yarn create react-app ,但结果是一样的。

Please let me know how I can solve this problem.请让我知道如何解决这个问题。

Error: Cannot find module 'C:\Users\me\React_projects\react-basic\test\node_modules\fs-extra\lib\index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:303:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:516:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Users\me\React_projects\react-basic\test\node_modules\react-scripts\scripts\init.js:17:12)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\Users\\me\\React_projects\\react-basic\\test\\node_modules\\fs-extra\\package.json',
  requestPath: 'fs-extra'
}

Aborting installation.
  node  has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting test/ from C:\Users\me\React_projects\react-basic
Done.

Solutions 1:解决方案1:

This issue related maybe to node module, path is updated and not targeted to index.js, so that its cant be load, or its happen since you have more than dirctory with the same file name...此问题可能与节点模块有关,路径已更新且未针对 index.js,因此无法加载它,或者由于您有多个具有相同文件名的目录而发生...

any way, to resolve this issue, try to do this:无论如何,要解决此问题,请尝试执行以下操作:

  1. Remove package-lock.json删除 package-lock.json
  2. Remove node_modules删除 node_modules
  3. Then install it again然后重新安装
  4. Then start然后开始

if you do this, you will remove old module and lock packagest and install it like a first install如果您这样做,您将删除旧模块并锁定 packagest 并像第一次安装一样安装它

================== Solutions 2: ==================解决方案2:

if prev steps not work, please make sure to test run via node direct, for example, get a copy for your project to desktop and try to install it and run it direct via node index.js and look what will be happen...如果前面的步骤不起作用,请确保通过节点直接测试运行,例如,将您的项目的副本复制到桌面并尝试安装它并通过节点 index.js 直接运行它,看看会发生什么......

================== Solutions 3: ==================解决方案3:

check your package.json and make sure the npm start is call a truth file-name / file-path which its exists...like "dev": "...../myProject/app.js" (its package.json in above level of app.js... check your package.json and make sure the npm start is call a truth file-name / file-path which its exists...like "dev": "...../myProject/app.js" (its package. json 在 app.js 的以上级别...

================== Solutions 4: ==================解决方案4:

make sure your node and npm/yarn its install globally and its can be accessed every where...via node -v for example...确保您的节点和 npm/yarn 全局安装,并且可以在任何地方访问它...例如通过 node -v ...

================== Solutions 5: ==================解决方案5:

make sure theirs no suffix empty space in file name or directory name确保他们的文件名或目录名中没有后缀空格

==================== =====================

for me, usually solution 1 or 3 or 5 resolve issue most time for our team issue like this...对我来说,通常解决方案 1 或 3 或 5 解决我们团队问题的大部分时间是这样的......

I wish one of these solution is work for you...我希望这些解决方案之一对您有用...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM