当我尝试运行我的应用程序时,为什么“ npm start”给我错误?

时间:2019-11-16 17:34:32

标签: node.js react-native npm

我不明白为什么我每次都会收到此错误 我尝试运行“ npm start”的时间。

> @ start E:\ReactNative\navigation_app
> expo start

internal/modules/cjs/loader.js:895
    throw err;
    ^

Error: Cannot find module 'C:\Users\Roei\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
    at Function.Module._load (internal/modules/cjs/loader.js:785:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1143:12)
    at internal/main/run_main_module.js:16:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
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\Roei\AppData\Roaming\npm-cache\_logs\2019-11-16T17_19_40_408Z-debug.log

这是我的package.json并尝试 找出那里出了什么问题

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^35.0.0",
    "expo-font": "^7.0.0",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
    "react-native-web": "^0.11.7"
  },
  "devDependencies": {
    "babel-preset-expo": "^7.1.0"
  },
  "private": true
}

我想解决这个问题,并了解磨损的原因。

3 个答案:

答案 0 :(得分:1)

您需要在全局npm i -g expo-cli上安装expo-cli

答案 1 :(得分:0)

您需要安装Expo。运行npm install或全局安装expo

答案 2 :(得分:0)

您没有在全球范围内安装Expo-CLI,这就是为什么您在本地项目中遇到此错误的原因。它需要Expo模块才能工作,但找不到它。因此,请运行npm install -g expo-cli,如果没有安装,请在此处粘贴错误代码。