当 Expo 应用程序不断出现此错误时,如何创建它?

Fai*_*sal 3 npm react-native expo

尝试了每一个可能的步骤

\n
    \n
  • 重新安装了 Node、NPM、Expo 等。
  • \n
  • 清理了缓存,也验证了它。
  • \n
  • 请帮忙,否则我将不得不重新安装 Ubuntu。
  • \n
\n
faisal@PC:~$ expo init\n\nMigrate to using:\n\xe2\x80\xba npx create-expo-app --template\n\n\xe2\x9c\x94 What would you like to name your app? \xe2\x80\xa6 my-app\n\xe2\x9c\x94 Choose a template: \xe2\x80\xba blank               a minimal app as clean as an empty canvas\nError downloading and extracting template package: TypeError: Cannot read properties of null (reading '0')\n\xe2\x9c\x96 Something went wrong while downloading and extracting the template.\n\nCan't read JSON file: /home/faisal/my-app/app.json\n\xe2\x94\x94\xe2\x94\x80 Cause: Error: ENOENT: no such file or directory, open '/home/faisal/my-app/app.json'\n    \xe2\x94\x9c\xe2\x94\x80 readAsync /usr/local/lib/node_modules/expo-cli/node_modules/@expo/json-file/src/JsonFile.ts:158:13\n    \xe2\x94\x9c\xe2\x94\x80 extractAndPrepareTemplateAppAsync /usr/local/lib/node_modules/expo-cli/src/commands/utils/extractTemplateAppAsync.ts:25:25\n    \xe2\x94\x94\xe2\x94\x80 actionAsync /usr/local/lib/node_modules/expo-cli/src/commands/initAsync.ts:290:19\nfaisal@PC:~$ npx create-expo-app myapp\n\xe2\x9c\x96 Something went wrong in downloading and extracting the project files: Could not find npm package "expo-template-blank@latest"\nError cloning template: Error: Could not find npm package "expo-template-blank@latest"\nfaisal@PC:~$ npm ls -g\n/usr/local/lib\n+-- @angular/cli@14.2.3\n+-- expo-cli@6.0.5\n+-- expo-template-blank@46.0.21\n`-- npm@8.19.2\n\nfaisal@PC:~$ npm -v\n8.19.2\n
Run Code Online (Sandbox Code Playgroud)\n

Fai*_*sal 6

使用 NVM 重新安装节点

\n

显然,我通过商店多次安装的节点出现了错误,因此我决定改用节点版本管理器。

\n

指示:

\n
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh\n
Run Code Online (Sandbox Code Playgroud)\n
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash\n
Run Code Online (Sandbox Code Playgroud)\n
source ~/.bashrc\n
Run Code Online (Sandbox Code Playgroud)\n
nvm list-remote\n
Run Code Online (Sandbox Code Playgroud)\n
nvm install v16.17.1\n
Run Code Online (Sandbox Code Playgroud)\n

是的,它有效:

\n
faisal@pc:~$ nvm install v16.17.1\nDownloading and installing node v16.17.1...\nDownloading https://nodejs.org/dist/v16.17.1/node-v16.17.1-linux-x64.tar.xz...\n######################################################################################################################################################################### 100.0%\nComputing checksum with sha256sum\nChecksums matched!\nNow using node v16.17.1 (npm v8.15.0)\nCreating default alias: default -> v16.17.1\nfaisal@pc:~$ expo init\n\nMigrate to using:\n\xe2\x80\xba npx create-expo-app --template\n\n\xe2\x9c\x94 What would you like to name your app? \xe2\x80\xa6 my-app\n\xe2\x9c\x94 Choose a template: \xe2\x80\xba blank               a minimal app as clean as an empty canvas\n\xe2\x9c\x94 Downloaded template.\n Using npm to install packages.\n\xe2\x9c\x94 Installed JavaScript dependencies.\n\n\xe2\x9c\x85 Your project is ready!\n\nTo run your project, navigate to the directory and run one of the following npm commands.\n\n- cd my-app\n- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.\n- npm run android\n- npm run ios # requires an iOS device or macOS for access to an iOS simulator\n- npm run web\n
Run Code Online (Sandbox Code Playgroud)\n