2

我刚刚完成了一门 React 课程并想开始练习。但是,我似乎无法使用 create-react-app 进行项目。

当我在命令行中使用create-react-app projectname时,它​​会开始安装,但它需要半个小时才能最终放弃并向我显示一堆我似乎无法理解的错误。当我观看有关如何使用 create-react-app 的教程时,它似乎应该可以正常工作并且应该在大约 12 秒内完成。

我已经尝试了很多事情:

  • 检查是否安装了 npm、node 和 npx
  • 以管理员身份运行 CMDer(我使用的 CLI)
  • npm install -g create-react-app 后跟 create-react-app 项目名称
  • npm install -g create-react-app 后跟 npm create-react-app 项目名称
  • npm init react-app 项目名称
  • 卸载 create-react-app 并再次安装
  • npx create-react 应用程序项目名称
  • 禁用我的防火墙和防病毒软件并执行上述所有操作
  • 清除 npm 缓存
  • 将 npm 更新到最新版本

这是我日志的最后一部分,最重要的是这只是一堆愚蠢的 SaveTree 行。

28892 silly saveTree `-- react@16.8.6
28893 warn ts-pnp@1.0.1 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
28894 verbose stack Error: EPERM: operation not permitted, rename 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\eslint-module-utils' -> 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\.eslint-module-utils.DELETE'
28895 verbose cwd C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest
28896 verbose Windows_NT 6.1.7601
28897 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
28898 verbose node v10.15.3
28899 verbose npm  v6.4.1
28900 error path C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\eslint-module-utils
28901 error code EPERM
28902 error errno -4048
28903 error syscall rename
28904 error Error: EPERM: operation not permitted, rename 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\eslint-module-utils' -> 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\.eslint-module-utils.DELETE'
28904 error  { [Error: EPERM: operation not permitted, rename 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\eslint-module-utils' -> 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\.eslint-module-utils.DELETE']
28904 error   cause:
28904 error    { Error: EPERM: operation not permitted, rename 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\eslint-module-utils' -> 'C:\Users\Dave\MyProjects\Portfolio\Tickomatic\newest\node_modules\.eslint-module-utils.DELETE'
28904 error      errno: -4048,
28904 error      code: 'EPERM',
28904 error      syscall: 'rename',
28904 error      path:
28904 error       'C:\\Users\\Dave\\MyProjects\\Portfolio\\Tickomatic\\newest\\node_modules\\eslint-module-utils',
28904 error      dest:
28904 error       'C:\\Users\\Dave\\MyProjects\\Portfolio\\Tickomatic\\newest\\node_modules\\.eslint-module-utils.DELETE' },
28904 error   stack:
28904 error    'Error: EPERM: operation not permitted, rename \'C:\\Users\\Dave\\MyProjects\\Portfolio\\Tickomatic\\newest\\node_modules\\eslint-module-utils\' -> \'C:\\Users\\Dave\\MyProjects\\Portfolio\\Tickomatic\\newest\\node_modules\\.eslint-module-utils.DELETE\'',
28904 error   errno: -4048,
28904 error   code: 'EPERM',
28904 error   syscall: 'rename',
28904 error   path:
28904 error    'C:\\Users\\Dave\\MyProjects\\Portfolio\\Tickomatic\\newest\\node_modules\\eslint-module-utils',
28904 error   dest:
28904 error    'C:\\Users\\Dave\\MyProjects\\Portfolio\\Tickomatic\\newest\\node_modules\\.eslint-module-utils.DELETE',
28904 error   parent: 'newest' }
28905 error The operation was rejected by your operating system.
28905 error It's possible that the file was already in use (by a text editor or antivirus),
28905 error or that you lack permissions to access it.
28905 error
28905 error If you believe this might be a permissions issue, please double-check the
28905 error permissions of the file and its containing directories, or try running
28905 error the command again as root/Administrator (though this is not recommended).
28906 verbose exit [ -4048, true ]

据我所知,它与无法重命名某个文件以及我的操作系统(在我的情况下为 Windows)因此拒绝整个事情有关。我不确定这是否正确,但这就是我能弄清楚的,我不知道如何解决这个问题。

有什么建议么?我似乎找不到解决方案,而且我不熟悉 WebPack,所以我现在无法及时手动设置项目。

提前感谢一堆,

戴夫

4

2 回答 2

2

如果您正在使用 Dropbox 或类似的东西来同步目录,则可能会导致此问题。

还尝试使用以下方法更新 npm:

npm install -g npm@latest
于 2019-04-03T16:40:20.550 回答
0

我通过以下方式全局更新了create-react-app

npm install -g create-react-app

它解决了我的问题。但是,我对 npm 使用 6.9.0 版本,对 node 使用 12.5.0 版本。

于 2019-12-05T09:11:37.917 回答