OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Type Error : Assignement to const variable declaring a variable as let (in config.js file and export to another file index.js

  • Thread starter Thread starter ayush singh
  • Start date Start date
A

ayush singh

Guest
In javascript(node JS), I have made a config.js file like below for export a name variable

Config.js

export let name ="ayush";

and I am importing the name variable in index.js file

index.js

import {name} from "./config.js";

name ="Rishabh"

console.log(name);

But I am getting Type Error:assignment to constant variable.

I have declared a variable as Let , then why still I am getting above error.

I am trying to change the variable name in another file. but I am getting the error, not able to understand what javascript concept is missing like (import is only read only).

<p>In javascript(node JS), I have made a config.js file like below for export a name variable</p>
<p>Config.js</p>
<p>export let name ="ayush";</p>
<p>and I am importing the name variable in index.js file</p>
<p>index.js</p>
<p>import {name} from "./config.js";</p>
<p>name ="Rishabh"</p>
<p>console.log(name);</p>
<p>But I am getting Type Error:assignment to constant variable.</p>
<p>I have declared a variable as Let , then why still I am getting above error.</p>
<p>I am trying to change the variable name in another file. but I am getting the error, not able to understand what javascript concept is missing like (import is only read only).</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top