NodeJS 在项目或这些目录中找不到axios:节点模块

k97glaaz  于 2023-03-12  发布在  Node.js
关注(0)|答案(1)|浏览(218)

我正在制作一个带有react native的移动的应用程序,每当我尝试导入Axios时,我无法导入它。我已经安装了Axios,一切正常。但我得到这个错误

Android Bundling failed 1097ms
Unable to resolve module axios from F:\HS International\araf\features\ChatWindow.js: axios could not be found within the project or in these directories:      
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
  1 | import { React, useState } from 'react';
  2 | import { Alert, ScrollView, SafeAreaView, Text, StyleSheet, TextInput, Button, TouchableHighlight, Image } from 'react-native'; 
> 3 | import axios from 'axios';
    |                    ^
  4 |
  5 | function ChatWindow(props) {
  6 |     const [userMessage, setUserMessage] = useState("");
kadbb459

kadbb4591#

我试着像你一样进口,但我想它有一些问题,你可以尝试这样要求它

const axios = require('axios').default;

相关问题