npm - React Native - 在没有 node_modules 文件夹的情况下保存项目,然后稍后创建它?

标签 npm react-native

我使用react-native init 创建了一个react native 项目。一切都很好,但现在我想将项目保存到一些源代码控制中,而不需要大型 node_modules 库(80mb)。

所以稍后(例如,当在另一台计算机上 checkout 源代码时)当我尝试重新创建文件夹时,我使用npm install。 但是现在当我运行 react-native start (我使用的是 Windows)时,我收到错误:
“找不到模块'.nodules/es5'”

react-native init 命令在 node_modules 中执行了 npm install 未执行的操作。 我错过了什么?

最佳答案

从您的描述中并不清楚您最初是如何创建该项目的。我建议使用 react-native init projectName 来正确创建项目。要运行 react-native,您需要首先全局安装 React Native - npm install -g react-native-cli

如果您使用 git 和 github 进行源代码控制 - react-native init 命令自动生成一个 .gitignore 文件。以下文件不被添加到源代码管理中。

OSX-

.DS_Store

Xcode-

构建/

*.pbx用户 !default.pbxuser *.模式1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 x用户数据 *.xccheckout *.移到一边 派生数据 *.hmap *.ipa *.xuserstate 项目.xcworkspace

Android/IJ

.想法 .gradle 本地属性

Node.js

节点模块/ npm-debug.log

因此,即使您运行 git add . (它在源代码管理中递归地跟踪所有文件),上述文件也不会被跟踪。

下次,如果您想在不同的机器上生成项目,只需运行

git 克隆 your_git_repo

然后

npm install

关于npm - React Native - 在没有 node_modules 文件夹的情况下保存项目,然后稍后创建它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36048116/

相关文章:

ios - 可以对 iPad OS 进行原生构建吗?

windows - 多个 npm 安装失败(EPERM 错误)

javascript - webpack中css-loader的作用是什么

node.js - 无法访问 NPM 环境变量

android -/bin/sh : adb: command not found

node.js - Sendbird SDK 不适用于 React Native

ios - React Native 0.60升级: Unknown type name 'MutexType'

gradle - React-Native ProductFlavors(错误类型 3 : Activity class does not exist)

node.js - 为什么 Nodejs 调试器在 npm 配置中运行时会忽略断点?

reactjs - 如何解决: "Definition for rule ' @typescript-eslint/consistent-type-assertions' was not found"