如何在使用yarn安装Next.js时解决此错误 - options.env['npm_config__p_a_c_k_a_g_e___l_o_c_k_']' 必须是不带空字节的字符串

问题描述 投票:0回答:1

使用

"yarn create next-app"
使用纱线创建 Next.js 应用程序时,它会抛出此错误 -
An unexpected error occurred: "The property 'options.env['npm_config__p_a_c_k_a_g_e___l_o_c_k_']' must be a string without null bytes. Received '\x00t\x00r\x00u\x00e\x00'"

节点版本 - 19.4.0

NPM 版本 - 9.7.2

纱线版本 - 1.22.19

create-next-app codeswear
这个命令工作正常,但我无法使用这个命令安装旧版本的 Next.js。

yarn create next-app@latest
yarn create next-app@12
- 我也尝试过这些命令,但没有用。

我尝试了很多方法,但没有任何效果。

next.js yarnpkg
1个回答
1
投票

我在处理 StencilJS 项目时遇到了类似的 Yarn 问题。 为我解决这个问题的方法是删除我的主目录中的

.npmrc
.yarnrc
文件。 如果您不想丢失这些文件的内容,请在弄乱它们之前先备份它们。

Yarn 在设置项目的过程中正在读取 NPM 和 Yarn 配置文件。 如果 Yarn 由于某种原因无法解析这些文件中的数据,则会抛出错误。

© www.soinside.com 2019 - 2024. All rights reserved.