如何创建指定的typescript RN版本?

Mor*_*ton 8 typescript react-native react-typescript

我输入命令以使用 typescript 创建 React Native 项目。

npx react-native init MyApp --template react-native-template-typescript
Run Code Online (Sandbox Code Playgroud)

包.json

"react-native": "0.63.2"

我想用打字稿创建 0.62.2,所以我尝试以下命令:

npx react-native init MyApp --version 0.62.2 --template react-native-template-typescript
Run Code Online (Sandbox Code Playgroud)

包.json

"react-native": "0.63.0"

是 0.63.0 而不是 0.62.2

为什么我无法使用 typescript 创建 0.62.2 ?

Jul*_* CB 21

对于typescript模板,react native的版本取决于react-native-template-typescript版本,例如:

  • 反应本机模板-typescript@6.5.9 --> 反应本机@0.63.4
  • 反应本机模板-typescript@6.5.7 --> 反应本机@0.63.3

因此,如果你想安装版本react-native@0.63.4,你需要应用这样的命令:

npx react-native init AwesomeTSProject --template react-native-template-typescript@6.5.9
Run Code Online (Sandbox Code Playgroud)

更多信息: react-native-template-typescript 版本


小智 -1

请尝试一下,

npx react-native init MyApp --version react-native@0.62.2 --template react-native-template-typescript
Run Code Online (Sandbox Code Playgroud)