reactjs - React Native:插件/预设文件不允许导出对象,只能导出函数
问题描述
我是 react-native 的新手,我正在尝试使用 mobx 建立一个项目(使用装饰器),但是在使用 expo start 命令时出现以下错误(我正在使用 expo)。
这是我的完整错误信息:
Failed building JavaScript bundle.
App.js: Plugin/Preset files are not allowed to export objects, only functions. In C:\xampp\htdocs\second-try\node_modules\babel-preset-react-native\index.js
events.js:292
throw er; // Unhandled 'error' event
^
Error: EPERM: operation not permitted, lstat 'C:\xampp\htdocs\second-try\node_modules\.staging\@babel'
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.<anonymous> (C:\xampp\htdocs\second-try\node_modules\sane\src\node_watcher.js:291:16)
at FSReqCallback.oncomplete (fs.js:167:21) {
errno: -4048,
code: 'EPERM',
syscall: 'lstat',
path: 'C:\\xampp\\htdocs\\second-try\\node_modules\\.staging\\@babel'
}
这是我的 babel 配置文件:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo', "react-native", "react-native-stage-0/decorator-support"],
};
};
还有我的 package.json 文件:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.7.0",
"@react-navigation/stack": "^5.7.0",
"axios": "^0.19.2",
"babel-preset-react-native-stage-0": "^1.0.1",
"expo": "~38.0.8",
"expo-status-bar": "^1.0.2",
"install": "^0.13.0",
"mobx": "^5.15.4",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-gesture-handler": "^1.6.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.7",
"react-native-screens": "^2.9.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.4.0"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"private": true
}
解决方案
推荐阅读
- javascript - 如何在base64图像预览中添加关闭按钮?
- c++ - 如何将 csv 文本文件读入二维数组?
- jsdoc - 使用 jsdoc 内联渲染“.md”文件?
- docker - VSCode 不断与远程容器断开连接
- ubuntu - -dev 包的实际构建命令是什么?
- javascript - [Vue 警告]:实例上未定义属性或方法“trendingMovies”
- python - Django 从 M2M 获取相关对象
- java - Scanner 类如何在带有输入的 java 中工作?
- node.js - Lambda 的预签名 URL 生成代码超时,在本地工作
- css - CSS在智能手机/移动设备中有所不同