node.js npm react-native

node.js - 由于未安装模块`expo`,因此无法确定您的项目使用的本机SDK版本

发布于 2021-01-21 18:10:24

当我npm start在powershell中运行时,显示以下错误错误:

PS C:\Users\UTKARSH\Desktop\react_native\my_project> npm start

@ start C:\Users\UTKARSH\Desktop\react_native\my_project
expo start

Starting project at C:\Users\UTKARSH\Desktop\react_native\my_project
Cannot determine which native SDK version your project uses because the module `expo` is not installed. Please install it with `yarn add expo` and try again.
ConfigError: Cannot determine which native SDK version your project uses because the module `expo` is not installed. Please install it with `yarn add expo` and try again.
    at Object.getExpoSDKVersion (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\config\src\Project.ts:22:9)
    at ensureConfigHasDefaultValues (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\config\src\Config.ts:419:22)
    at fillAndReturnConfig (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\config\src\Config.ts:101:10)
    at getConfig (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\config\src\Config.ts:137:10)
    at configureProjectAsync (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:288:25)
    at action (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:164:34)
    at C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:341:16
    at Command.<anonymous> (C:\Users\UTKARSH\AppData\Roaming\npm\node_modules\expo-cli\src\exp.ts:82:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\UTKARSH\AppData\Roaming\npm-cache\_logs\2020-05-15T07_09_48_901Z-debug.log
PS C:\Users\UTKARSH\Desktop\react_native\my_project> clear

我怎样才能解决这个问题?

查看更多

提问者
utkarsh sharma
被浏览
0
2,521 2020-09-24 19:56

我只是有这个问题。我这样解决了:

我在NVM上使用了旧的Node版本。我更改为上一个节点版本

nvm use 12.x.x

nvm和更新:

yarn global add expo-cli

但是,您需要运行

npm install expo-cli --global

npm之后,我改回旧版本:

nvm use 10.x.x

跑了

yarn start

要么

npm start

这解决了问题。