NextJs应用初始化失败- ENOENT npm错误

e5nszbig  于 2023-06-05  发布在  其他
关注(0)|答案(1)|浏览(321)

我正在尝试使用以下命令初始化Nextjs应用程序:npx create-next-app@latest,但是编译失败了大约10秒,我得到了这个错误:

npm ERR! Windows_NT 10.0.19045
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Alex\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-exact" "--save" "react" "react-dom" "next" "typescript" "@types/react" "@types/node" "@types/react-dom" "tailwindcss" "postcss" "autoprefixer" "eslint" "eslint-config-next"
npm ERR! node v18.16.0
npm ERR! npm  v2.15.12
npm ERR! path C:\Users\Alex\Desktop\anim8\node_modules\@types\react-dom\package.json
npm ERR! code ENOTDIR
npm ERR! errno -4058
npm ERR! syscall open

npm ERR! ENOENT: no such file or directory, open 'C:\Users\Alex\Desktop\anim8\node_modules\@types\react-dom\package.json'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Alex\Desktop\anim8\npm-debug.log

我的npm和node更新为latest,所以我不确定这里发生了什么

dgenwo3n

dgenwo3n1#

问题是由于我的计算机上的权限。由于某种原因,我的操作系统阻塞了操作,解决方法是以admin身份运行cmd,然后运行npx create-next-app@latest
我不确定这是否是最好的解决方案,但它现在有效。
此外,您还必须对应用程序本身给予权限。
文件夹->属性->安全->用户->编辑->完全控制

相关问题