microsoft / TypeScript-React-Native-Starter

A starter template for TypeScript and React Native with a detailed README describing how to use the two together.
MIT License
1.91k stars 211 forks source link

Command `run-ios` unrecognized after adding typescript modules #22

Open JakeXu opened 6 years ago

JakeXu commented 6 years ago

Follow the guide, I get the below package.json:

{
  "name": "one",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.2.0",
    "react-native": "0.52.0"
  },
  "devDependencies": {
    "@types/enzyme": "^3.1.6",
    "@types/jest": "^22.0.1",
    "@types/react": "^16.0.34",
    "@types/react-native": "^0.51.9",
    "@types/react-test-renderer": "^16.0.0",
    "babel-jest": "22.0.4",
    "babel-preset-react-native": "4.0.0",
    "enzyme": "^3.3.0",
    "jest": "22.0.5",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "^16.2.0",
    "react-test-renderer": "16.2.0",
    "ts-jest": "^22.0.1",
    "typescript": "^2.6.2"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "transform": {
      "^.+\\.(js)$": "<rootDir>/node_modules/babel-jest",
      "\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    "testPathIgnorePatterns": [
      "\\.snap$",
      "<rootDir>/node_modules/",
      "<rootDir>/lib/"
    ],
    "cacheDirectory": ".jest/cache"
  }
}
react-native -v

react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory

When I run this command line:

npm install --save-dev @types/jest @types/react @types/react-native @types/react-test-renderer

Then I run

react-native run-ios

got the tips:


Command `run-ios` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.

How should I do for it? Everybody can give me some suggestions, Thank you in advance!

HofmannZ commented 6 years ago

Hi,

Try npm install from the root of your project, seems like react-native is not installed.

JakeXu commented 6 years ago

I have found the solution, but I don't know why? After running react-native init project-name , you MUST run the below command FIRST,

npm remove jest -D
npm i jest -D

Then, follow the manual, everything will be ok, work fine for you! It costs me so much time!!!

VenkataVamsi1991 commented 5 years ago

Hi @JakeXu I have done what you have said

npm remove jest -D npm i jest -D and went to the project and done run-its as react-native run-its but got same error

my project is git clone https://github.com/tassdr/react-native-template.git

downloaded there and trying to run in my macOS but error remains same

Admins-MacBook-Pro:react-native-template admin$ react-native run-ios error iOS project folder not found. Are you sure this is a React Native project?. Run CLI with --verbose flag for more details. Admins-MacBook-Pro:react-native-template admin$

please help me

JeevaS0722 commented 4 years ago

Try this Cmd wrok for me npx react-native run-ios