Module not found: Error: Can't resolve 'axios' in '/opt/render/project/src/src'

Hey,
I thinks that I did everything as needed:
My build command: npm install; npm run build
My start command: npm run start

And in my React app Im using Axios lib, once as module by importing it: import axios from ‘axios’;

import axios from 'axios';
import config from './config/devconfig';

const instance = axios.create({
  baseURL: config.apiUrl,
});

instance.interceptors.request.use((config) => {
  config.headers.Authorization = window.localStorage.getItem('token');
  return config;
});

export default instance;

And other times I use as custom module: import axios from ‘…/…/axios’;

And when I try to deploy my app to Render I get the following error:

Mar 11 10:22:51 PM  > client@0.1.0 build /opt/render/project/src
Mar 11 10:22:51 PM  > react-scripts build
Mar 11 10:22:51 PM  
Mar 11 10:22:52 PM  Creating an optimized production build...
Mar 11 10:22:55 PM  Failed to compile.
Mar 11 10:22:55 PM  
Mar 11 10:22:55 PM  Module not found: Error: Can't resolve 'axios' in '/opt/render/project/src/src'
Mar 11 10:22:55 PM  Did you mean './axios'?
Mar 11 10:22:55 PM  Requests that should resolve in the current directory need to start with './'.
Mar 11 10:22:55 PM  Requests that start with a name are treated as module requests and resolve within module directories (node_modules, /opt/render/project/src/node_modules).
Mar 11 10:22:55 PM  If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
Mar 11 10:22:55 PM  
Mar 11 10:22:55 PM  
Mar 11 10:22:55 PM  npm ERR! code ELIFECYCLE
Mar 11 10:22:55 PM  npm ERR! errno 1
Mar 11 10:22:55 PM  npm ERR! client@0.1.0 build: `react-scripts build`
Mar 11 10:22:55 PM  npm ERR! Exit status 1
Mar 11 10:22:55 PM  npm ERR!
Mar 11 10:22:55 PM  npm ERR! Failed at the client@0.1.0 build script.
Mar 11 10:22:55 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Mar 11 10:22:55 PM  
Mar 11 10:22:55 PM  npm ERR! A complete log of this run can be found in:
Mar 11 10:22:55 PM  npm ERR!     /opt/render/.cache/_logs/2023-03-11T21_22_55_816Z-debug.log
Mar 11 10:22:55 PM  ==> Build failed 😞

What is went wrong with deploy service? Locally build and start work fine. For me looks like npm modules were not installed from some reason.

Thanks in advance for the help =)

issue found and resolved. my mistakes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.