node.js - create-react-app 无法正常工作并且需要很长时间,有什么建议吗?

标签 node.js reactjs npm create-react-app npx

我刚刚学完 React 类(class)并想开始练习。但是,我似乎无法使用 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 `-- <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e39186828097a3d2d5cddbcdd5" rel="noreferrer noopener nofollow">[email protected]</a>
28893 warn <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5622257b263826166778667867" rel="noreferrer noopener nofollow">[email protected]</a> 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 不熟悉,所以目前无法手动设置项目。

提前致谢,

戴夫

最佳答案

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

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

npm install -g npm@latest

关于node.js - create-react-app 无法正常工作并且需要很长时间,有什么建议吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55499898/

相关文章:

javascript - Json-server 依赖于 uuid 而不是 id

node.js - Ember-CLI "You don' t 有权访问此文件”

reactjs - 在 React Native 中渲染逗号分隔的值字符串

reactjs - 在 Reactjs 中设置状态变量的正确方法是什么?这些方法之间有什么区别?

javascript - Express.js 中设置和获取 cookie 失败

javascript - 使用 node.js 进行垃圾收集

reactjs - Gatsby.js : Preprocessing Relative Path Links in Markdown

node.js - WebdriverIO : Dot ('.' ) is not recognized as an internal, 或外部命令

angularjs - 通过bamboo build调用package.json中的npm脚本触发构建

node.js - Nest.js - process.env.npm_package_description 未返回正确的值