📌  相关文章
📜  laravel 在 .资源 js bootstrap.js 8:15-31 找不到模块:错误:无法解析“axios”-Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:17:14.328000             🧑  作者: Mango

Laravel Error: Cannot find module 'axios' in resources/js/bootstrap.js line 8:15-31

If you are facing this error while working with Laravel, it means that the required module 'axios' could not be found in your project. Axios is a popular JavaScript library used for making HTTP requests from a web browser.

To resolve this error, you can follow these steps:

  1. Install Axios in your Laravel project using NPM. NPM is a package manager that allows you to easily install and manage third-party packages in your project. Run the following command in your terminal:
npm install axios
  1. Once Axios is installed, you need to import it in your resources/js/bootstrap.js file. You can add the following line at the top of your file:
import axios from 'axios';
  1. Save the file and run your Laravel project again. The error should be resolved now.

Note: If you are using Laravel Mix for compiling your assets, you need to run the following command to recompile your assets:

npm run dev

This will compile your assets and add the Axios module to your assets.

In conclusion, the error occurs because Laravel could not find the required 'axios' module in your project. You can resolve this error by installing Axios using NPM and importing it in your bootstrap.js file.