react-native - 无法解析模块 multer
问题描述
在 Android 设备上运行我的 react-native 项目时出现错误。
我已经尝试了很多东西。把node_modules、、clear npm cache
yarn也去掉,用yarn和npm安装,不要解析。
怎么了?
Error: Unable to resolve module `util` from `node_modules/multer/lib/multer-error.js`: util 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-*
也已经尝试过错误消息中指示的建议。
包.json
{
"name": "svm",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/datetimepicker": "^2.3.2",
"@react-native-community/masked-view": "^0.1.6",
"@react-navigation/drawer": "^5.4.0",
"axios": "^0.19.2",
"formik": "^2.1.4",
"moment": "^2.24.0",
"native-base": "^2.13.8",
"react": "16.9.0",
"react-native": "^0.62.2",
"react-native-elements": "^1.2.7",
"react-native-ftp": "^1.0.1",
"react-native-gesture-handler": "^1.5.6",
"react-native-image-picker": "^2.3.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-masked-text": "^1.13.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.2",
"react-native-screens": "^2.0.0-beta.2",
"react-native-sound": "^0.11.0",
"react-native-vector-icons": "^6.6.0",
"react-native-youtube": "^2.0.1",
"react-navigation": "^4.1.1",
"ssh2-sftp-client": "^5.1.2",
"styled-components": "^5.0.1",
"yup": "^0.28.1"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"multer": "^1.4.2",
"multer-sftp": "^1.1.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
解决方案
Multer 被列为开发依赖项。我猜您在测试时已经构建了用于生产的应用程序。所以包没有加载。
将“multer”:“^1.4.2”依赖项从“devDependencies”移动到“dependencies”应该可能会解决它。
推荐阅读
- iis - IIS web.config condition
- java - Gradle 多项目 - 未找到包
- angular - Angular:发布请求成为选项
- css - 伪元素
- sql - Comparing 2 tables and updating a column based on results?
- python - how to remove points in an array around NaN values within a window
- deployment - Serverless: Service files not changed. Skipping deployment
- r - 使用条件删除行
- java - 为什么物理后退按钮与应用程序后退按钮的工作方式不同
- c# - C# - 在 try 块之外定义 var 并将其返回