我无法解决本地npm依赖性,似乎没有任何作用。我有两个文件夹:library
和sampleapp
。我希望sampleapp
包含一个React Native应用程序,该应用程序将library
作为npm软件包安装,并且本机代码将从那里导入东西。
sampleapp
package.json:
{
"name": "sampleapp",
"version": "0.0.1",
"private": true,
"dependencies": {
"@babel/runtime": "^7.3.1",
"library": "file:../library",
"react": "16.6.3",
"react-native": "0.58.3"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
还有library
package.json:
{
"name": "library",
"version": "0.0.1",
"main": "./wrapper.js",
"dependencies": {
"@babel/runtime": "^7.3.1"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0"
}
}
该库公开的 wrapper.json
文件非常简单:
const test = () => {
return 'test';
}
module.exports = test;
现在发生的是,当我运行npm i && react-native run-android
时,总是出现以下错误:
error: bundling failed: Error: Unable to resolve module `library` from `/Users/user.name/Documents/Project/sampleapp/App.js`: Module `library` does not exist in the Haste module map.
我将其简单地导入为import test from "library"
。
怎么了?