Expo 项目中的 Expo-notifications 配置插件错误: 我正在开发一个 Expo 项目,并且遇到错误消息“Package 'expo-notifications' does not contains a valid config plugin.”我已经检查了软件包的安装和兼容性,但错误仍然存在。有其他人遇到过这个问题吗?可能是什么原因造成的?
当我运行
npx expo prebuild
时,我收到此错误
当我运行 npx eas build
显示相同的错误。
Starting project at D:\Projects\GoalSettingApp\client
PluginError: Package "expo-notifications" does not contain a valid config plugin.
Learn more: https://docs.expo.dev/guides/config-plugins/#creating-a-plugin
Unexpected token 'export'
D:\Projects\...\client\node_modules\expo-notifications\build\index.js:1
export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';
^^^^^^
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at requirePluginFile (D:\Projects\...\client\node_modules\@expo\config-plugins\build\utils\plugin-resolver.js:214:12)
at resolveConfigPluginFunctionWithInfo (D:\Projects\...\client\node_modules\@expo\config-plugins\build\utils\plugin-resolver.js:155:14)
这是我的 babe.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
'react-native-reanimated/plugin'
],
};
};
这是我的package.json
{
"name": "client",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@babel/preset-env": "^7.1.6",
"@expo/vector-icons": "^13.0.0",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-community/datetimepicker": "6.7.3",
"@react-native-community/slider": "^4.4.2",
"@react-navigation/bottom-tabs": "^6.5.8",
"@react-navigation/drawer": "^6.6.3",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"@react-navigation/stack": "^6.3.17",
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.4.0",
"expo": "^49.0.6",
"expo-av": "~13.2.1",
"expo-constants": "~14.2.1",
"expo-device": "~5.2.1",
"expo-linear-gradient": "~12.1.2",
"expo-media-library": "~15.2.3",
"expo-modules-autolinking": "^0.8.1",
"expo-notifications": "^0.8.2",
"expo-splash-screen": "^0.20.5",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-gesture-handler": "~2.9.0",
"react-native-modal-datetime-picker": "^17.0.0",
"react-native-qrcode-svg": "^6.2.0",
"react-native-reanimated": "~2.14.4",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-svg": "13.4.0",
"react-native-switch-selector": "^2.3.0",
"react-native-vector-icons": "^10.0.0",
"react-redux": "^8.1.1",
"recyclerlistview": "^4.2.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.0"
},
"private": true
}
这是
app.json
中的插件
[
"expo-notifications",
{
"icon": "./assets/icon.png",
"color": "#ffffff"
}
]
],```
What I need to change my code so that the error no longer occur?
实际上我使用了错误版本的博览会通知。我应该使用 ^0.18.2 而不是 ^0.8.2。
如果有人遇到同样的问题,请考虑检查您的软件包版本。