React native 可以安装npm<;文件夹>;`文件夹是否与react native一起使用?

React native 可以安装npm<;文件夹>;`文件夹是否与react native一起使用?,react-native,npm,React Native,Npm,我是否应该能够作为react本机应用程序的依赖项安装npm包的文件夹 在过去,我能够通过这些命令行实用程序的一些组合来实现这一点(尽管我可能使用了纱线而不是npm),但不幸的是,我没有记录细节 以下是我运行的命令: $ uname -v Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_6 $ mkdir testapp $ cd testapp $ npx

我是否应该能够作为react本机应用程序的依赖项安装npm包的文件夹

在过去,我能够通过这些命令行实用程序的一些组合来实现这一点(尽管我可能使用了纱线而不是npm),但不幸的是,我没有记录细节

以下是我运行的命令:

$ uname -v
Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_6
$ mkdir testapp
$ cd testapp
$ npx -v
6.9.0
$ npx react-native --version
3.0.4
$ npx react-native init AwesomeProject
$ create-react-native-module --version
0.13.0
$ create-react-native-module MyFancyLibrary
$ cd AwesomeProject
$ npm install ../react-native-my-fancy-library
$ cd ios
$ npx pod --version
1.7.5
$ vi App.js ; insert `import MyFancyLibrary from 'react-native-my-fancy-library';`
$ pod install
$ npx react-native run-ios
以下是错误:

Error: undefined Unable to resolve module `react-native-my-fancy-library` from `App.js`: react-native-my-fancy-library could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules: rm -rf node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*

showCompileError
    index.bundle?platform=ios&dev=true&minify=false:34608:26
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:34547:29
emit
    index.bundle?platform=ios&dev=true&minify=false:35027:35
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:34874:23
dispatchEvent
    index.bundle?platform=ios&dev=true&minify=false:32345:31
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:32979:31
emit
    index.bundle?platform=ios&dev=true&minify=false:6932:42
__callFunction
    index.bundle?platform=ios&dev=true&minify=false:2683:49
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:2396:31
__guard
    index.bundle?platform=ios&dev=true&minify=false:2637:15
callFunctionReturnFlushedQueue
    index.bundle?platform=ios&dev=true&minify=false:2395:21
callFunctionReturnFlushedQueue
    [native code]:0
错误:未定义无法从'App.js'解析模块'react native my fancy library':在项目中找不到react native my fancy library。
如果确定模块存在,请尝试以下步骤:
1.清除看守人手表:看守人手表删除所有
2.删除节点_模块:rm-rf节点_模块并运行安装
3.重置高速缓存:纱线开始--重置高速缓存
4.删除缓存:rm-rf/tmp/metro-*
显示编译错误
index.bundle?platform=ios&dev=true&minify=false:34608:26
index.bundle?platform=ios&dev=true&minify=false:34547:29
发出
index.bundle?platform=ios&dev=true&minify=false:35027:35
index.bundle?platform=ios&dev=true&minify=false:34874:23
调度事件
index.bundle?platform=ios&dev=true&minify=false:32345:31
index.bundle?platform=ios&dev=true&minify=false:32979:31
发出
index.bundle?platform=ios&dev=true&minify=false:6932:42
__调用函数
index.bundle?platform=ios&dev=true&minify=false:2683:49
index.bundle?platform=ios&dev=true&minify=false:2396:31
__卫兵
index.bundle?platform=ios&dev=true&minify=false:2637:15
callFunctionReturnFlushedQueue
index.bundle?platform=ios&dev=true&minify=false:2395:21
callFunctionReturnFlushedQueue
[本机代码]:0
以下是命令和输出的完整日志:

$mkdir testapp
$cd testapp/
$npx react native init AwesomeProject
这将指导您在中创建新的React本机项目
testapp/AwesomeProject
使用纱线v1.21.1
正在安装react native。。。
纱线添加v1.21.1
信息找不到锁文件。

[1/4]实际上,我在“创建本机模块”一文中给出了答案,如果这对您有帮助,请尝试。