尝试安装react-native -floating-action时发生错误

时间:2018-12-31 16:59:48

标签: reactjs react-native npm npm-install

当我尝试安装某些软件包时 喜欢: 反应本机浮动动作

或:

react-native-action-button

我正在运行

npm i react-native-floating-action --save

当我运行react-native link

我收到此错误:

PS C:\Projects\projectname> react-native link
rnpm-install info Linking assets to ios project
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'pbxprojPath' of null
Please file an issue here: https://github.com/facebook/react-native/issues

Cannot read property 'pbxprojPath' of null

TypeError: Cannot read property 'pbxprojPath' of null
    at Object.linkAssetsIOS [as copyAssets] (C:\Projects\projectname\node_modules\react-native\local-cli\link\ios\copyAssets.js:24:41)
    at C:\Projects\projectname\node_modules\react-native\local-cli\link\link.js:104:12
    at Array.forEach (<anonymous>)
    at linkAssets (C:\Projects\projectname\node_modules\react-native\local-cli\link\link.js:94:28)
    at C:\Projects\projectname\node_modules\react-native\local-cli\link\link.js:171:30

这些是我的版本:

react-native-cli: 2.0.1
react-native: 0.57.1
 npm --version
6.4.1

 expo --version
2.6.14

3 个答案:

答案 0 :(得分:1)

Expo不支持链接的二进制文件。如果需要链接的二进制文件,则必须首先Eject from Expo to ExpoKit或使用react-native init MyProjName

初始化项目

参考

  

如果您知道最终将需要包含您自己的本机代码,那么Expo仍然是入门的好方法。在这种情况下,您只需要最终“弹出”即可创建自己的本机版本。如果您确实弹出,则需要“使用本机代码构建项目”说明才能继续进行您的项目。

     

https://facebook.github.io/react-native/docs/getting-started.html

答案 1 :(得分:1)

这对我有用:

npm更新

本机链接

答案 2 :(得分:0)

最终,我找到了问题,

我需要运行import numpy as np from keras import optimizers from keras import losses from sklearn.model_selection import train_test_split from model import create_model def data_loader(images, pos): while(True): for i in range(0, images.shape[0], 64): if (i+64) < images.shape[0]: img_batch = images[i:i+64] pos_batch = pos[i:i+64] yield img_batch, pos_batch else: img_batch = images[i:] pos_batch = pos[i:] yield img_batch, pos_batch def main(): model = create_model() sgd = optimizers.Adadelta(lr=0.01, rho=0.95, epsilon=None, decay=0.0) model.compile(loss=losses.mean_squared_error, optimizer=sgd) print("traning") data = np.load("data.npz") images = data['images'] pos = data['pos'] x_train, x_test, y_train, y_test = train_test_split(images, pos, test_size=0.33, random_state=42) model.fit_generator(data_loader(x_train, y_train), steps_per_epoch=x_train.shape[0]//64, validation_data=data_loader(x_test, y_test), \ validation_steps = x_test.shape[0]//64, epochs=1) model.save('test.h5') model.save_weights('test_weights.h5') print("training done") if __name__ == '__main__': main() ,并且package.json中的react-native版本与node_modules版本不同

在packge.json上写^ 0.57.8(当前的本机版本):

react-native upgrade

运行"react-native": "^0.57.8",

在package.json中为项目设置名称:

npm install

并运行

"name":"somename"

一切都很好

在我看来,这始终是带有本机错误的版本的问题