close

[Solved] Uncaught SyntaxError: The requested module ‘./add.js’ does not provide an export named ‘add’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Uncaught SyntaxError: The requested module ‘./add.js’ does not provide an export named ‘add’ in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How To Solve Uncaught SyntaxError: The requested module ‘./add.js’ does not provide an export named ‘add’ Error ?

  1. How To Solve Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add' Error?

    To Solve Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add' Error Name your export instead of using default. It should look like this Or Use the export default syntax.

  2. Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add'

    To Solve Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add' Error Name your export instead of using default. It should look like this Or Use the export default syntax.

Solution 1

Name your export instead of using default. It should look like this.

// add.js
export const add =  (a, b) =>  a + b;
// OR
// export const add = function(a, b) { return a+b };

// app.js
import { add } from './add';

Solution 2

Use the export default syntax. It looks like this

// add.js
export default function add(a, b) {
  return a + b;
}

// app.js
import add from './add';

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment