【问题标题】:Error: ": Unexpected token \u0000 in JSON at position 0" when using yarn to add a react package错误:“:位置 0 处 JSON 中的意外令牌 \u0000”使用纱线添加反应包时
【发布时间】:2021-10-14 04:56:38
【问题描述】:

我正在尝试通过 yarn yarn add react-native-gesture-handler@1.10.2 安装以下包。我阅读了这个问题的多个答案,但没有一个有用。我认为问题可能来自于我使用的是 windows 计算机但不知道如何解决它。

每当您尝试执行yarn add ..@version 时,我都会收到以下错误:

yarn add v1.22.11
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is 
advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "C:\\Users\\...\\AppData\\Local\\Yarn\\Cache\\v6\\npm-unbox-primitive-1.0.1-085e215625ec3162574dc8859abee78a59b14471-integrity\\node_modules\\unbox-primitive\\.yarn-metadata.json: 
Unexpected token \u0000 in JSON at position 0".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\...\\OneDrive\\Documents\\GitHub\\wc_app\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

【问题讨论】:

    标签: npm expo yarnpkg git-bash


    【解决方案1】:

    我在 Windows 机器上创建最新的 react native 项目(0.65)时遇到了类似的问题

    错误发生意外错误:“C:\Users\arefin\AppData\Local\Yarn\Cache\v6\npm-is-ci-3.0.0-c7e7be3c9d8eef7d0fa144390bd1e4b88dc4c994-integrity\node_modules\is-ci\.yarn- metadata.json: 位置 0 处 JSON 中的意外令牌 \u0000"。

    我的react native开发系统配置如下:

    • 节点--版本:v15.7.0
    • yarn --version: 1.22.5
    • npm --version: 7.12.1
    • java --version: java 15.0.2 2021-01-19

    我在下面使用了这些命令,最终解决了我的问题:

    yarn init && yarn add react-native && yarn react-native init 消费收益

    我在here找到的

    【讨论】:

    • 谢谢!我设法通过重新启动整个纱线来解决它。 Npm 和 yarn 正在“崩溃”,因为我同时(错误地)设置了两个项目
    猜你喜欢
    • 2022-07-11
    • 1970-01-01
    • 2020-04-23
    • 2020-11-20
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 2021-07-01
    • 2016-12-13
    相关资源
    最近更新 更多