npx create-react-app myapp 错误“\AppData\Roaming\npm-cache\_npx748”在 appdata 文件夹中不包含 package.json 文件
npx create-react-app myapp error "\AppData\Roaming\npm-cache\_npx\19748" does not contain a package.json file in appdata folder
OS: Windows
为了使用 npx 创建 React 应用程序,我编写了以下命令:
npx create-react-app myapp
显示此错误:
npm ERR! Could not install from "myusername\AppData\Roaming\npm-cache\_npx748" as it does not contain a package.json file.
我该如何解决?
此错误通常发生在 PC 名称包含 space 之类的
时
mycomputer name
你应该通过重新定义你的 npm 缓存根来解决这个问题有一个简单的解决方法来解决这个问题。 8.3 应使用 DOS 路径格式。在管理模式下打开命令提示符,然后 cd 到 C:\Users 和 运行 这个命令:
C:\Users>dir /x
并找到所需目录的短路径,即用户名让我们说它是 MYCOMP~1(它并不总是 MYCOMP~1)
尝试:
npm config set cache "C:\Users\MYCOMP~1\AppData\Roaming\npm-cache" --global
注意电脑名称中的 space 字符,您应该使用从命令提示符处获得的字符
现在使用:
npx create-react-app myapp
编码愉快!!!
我参加聚会迟到了,但我的 PC 目录中的名称 space 也遇到了同样的问题。我为解决这个问题所做的是:
- 在 C 以外的其他位置创建空文件夹,例如在名为 folder/npm-cache
的 D 目录中
- 在航站楼 I 运行 中:
npm config set cache "D:\name-cache\AppData\Roaming\npm-cache" --global
- 如果您仍希望将其放在用户名 space 中的当前路径上
喜欢“C:\Users\Firstname Lastname\AppData\Roaming\npm-cache”
您可以将 space 之后的字符串替换为 "~1"
npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global
正如他们上面所说的,这个错误通常发生在 PC 名称包含 space 之类的
时
第 1 步:导航到 C:\Users>
和 运行 C:\Users>dir /x
USERPC~1 是我系统上 USER PC 的替代名称。注意 USER 和 PC 之间的 space
第 2 步: 现在 运行 npm config set cache "C:\Users\USERPC~1\AppData\Roaming\npm-cache" --global
如果您有大坝萨姆 use DAMSAM~1
第 3 步: 现在 运行 npm config edit
。它将打开一个 txt 文件,查找缓存的位置,并检查上面 运行 的路径是否与 txt 文件中的路径匹配
步骤 4:如果匹配保存文件和 运行 npx create-react-app
。它会 运行。如果不像我的情况那样手动将路径更改为 "C:\Users\USERPC~1\AppData\Roaming\npm-cache"
。
第 5 步: 确保保存 .txt 文件。然后 运行 npx create-react-app
命令
OS: Windows
为了使用 npx 创建 React 应用程序,我编写了以下命令:
npx create-react-app myapp
显示此错误:
npm ERR! Could not install from "myusername\AppData\Roaming\npm-cache\_npx748" as it does not contain a package.json file.
我该如何解决?
此错误通常发生在 PC 名称包含 space 之类的
时mycomputer name
你应该通过重新定义你的 npm 缓存根来解决这个问题有一个简单的解决方法来解决这个问题。 8.3 应使用 DOS 路径格式。在管理模式下打开命令提示符,然后 cd 到 C:\Users 和 运行 这个命令:
C:\Users>dir /x
并找到所需目录的短路径,即用户名让我们说它是 MYCOMP~1(它并不总是 MYCOMP~1) 尝试:
npm config set cache "C:\Users\MYCOMP~1\AppData\Roaming\npm-cache" --global
注意电脑名称中的 space 字符,您应该使用从命令提示符处获得的字符 现在使用:
npx create-react-app myapp
编码愉快!!!
我参加聚会迟到了,但我的 PC 目录中的名称 space 也遇到了同样的问题。我为解决这个问题所做的是:
- 在 C 以外的其他位置创建空文件夹,例如在名为 folder/npm-cache 的 D 目录中
- 在航站楼 I 运行 中:
npm config set cache "D:\name-cache\AppData\Roaming\npm-cache" --global
- 如果您仍希望将其放在用户名 space 中的当前路径上
喜欢“C:\Users\Firstname Lastname\AppData\Roaming\npm-cache” 您可以将 space 之后的字符串替换为 "~1"
npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global
正如他们上面所说的,这个错误通常发生在 PC 名称包含 space 之类的
时
第 1 步:导航到 C:\Users>
和 运行 C:\Users>dir /x
USERPC~1 是我系统上 USER PC 的替代名称。注意 USER 和 PC 之间的 space
第 2 步: 现在 运行 npm config set cache "C:\Users\USERPC~1\AppData\Roaming\npm-cache" --global
如果您有大坝萨姆 use DAMSAM~1
第 3 步: 现在 运行 npm config edit
。它将打开一个 txt 文件,查找缓存的位置,并检查上面 运行 的路径是否与 txt 文件中的路径匹配
步骤 4:如果匹配保存文件和 运行 npx create-react-app
。它会 运行。如果不像我的情况那样手动将路径更改为 "C:\Users\USERPC~1\AppData\Roaming\npm-cache"
。
第 5 步: 确保保存 .txt 文件。然后 运行 npx create-react-app
命令