在Google Drive创建React App时出现ENOTDIR错误,请求帮助
在Google Drive目录下创建React App时出现ENOTDIR错误的解决办法
问题场景
在Google Drive挂载目录(如G:\My Drive)执行npx create-react-app test-app时,触发以下ENOTDIR错误,而本地文件夹和OneDrive目录下操作正常:
PS G:\My Drive> npx create-react-app test-app Creating a new React app in G:\My Drive\test-app. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template... npm ERR! code ENOTDIR npm ERR! syscall mkdir npm ERR! path G:\My Drive\test-app\node_modules\babel-jest\node_modules npm ERR! errno -4052 npm ERR! ENOTDIR: not a directory, mkdir 'G:\My Drive\test-app\node_modules\babel-jest\node_modules' npm ERR! A complete log of this run can be found in: C:\Users\jvilf\AppData\Local\npm-cache\_logs\2024-04-14T23_37_26_820Z-debug-0.log Aborting installation. npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed. Deleting generated file... package.json Deleting test-app/ from G:\My Drive Done.
解决方法
方法1:本地创建后同步到Google Drive
- 打开终端,切换到本地非同步目录(例如
C:\Users\你的用户名\Documents) - 执行
npx create-react-app test-app,等待项目创建完成 - 将生成的
test-app文件夹完整复制到G:\My Drive目录下 - 后续开发可直接在Google Drive的项目目录中运行
npm start、npm run build等命令
方法2:暂停Google Drive同步后创建项目
- 右键任务栏的Google Drive图标,选择「暂停同步」
- 在
G:\My Drive目录下执行npx create-react-app test-app - 项目创建完成后,重新右键Google Drive图标,选择「恢复同步」
方法3:使用npm无符号链接参数创建
- 直接执行以下命令,禁用npm创建符号链接的操作:
npx create-react-app test-app -- --no-bin-links
注意事项
- Google Drive同步存在延迟,操作完成后等待几秒,确保文件同步完毕再执行后续命令
- 尽量避免在Google Drive目录下频繁重建
node_modules目录,减少同步冲突概率
内容的提问来源于stack exchange,提问作者jazoe
相关产品推荐
相关产品推荐

