I'm trying to export this js file.
const student =
{
studentID : 1,
}
export {student}
this is my second file in which I'm trying to import it.
import {student} from "./studentId";
console.log(student);
It's not importing it and throwing this error .
Failed to load resource: the server responded with a status of 404 ()
Look at the error message. You are getting a 404 Not Found error.
Node.js does not need a file extension when loading a module. It has access to the file system and can look at all the files in a directory.
Web browsers do not have any way of telling if the URL you specified should have a .js
or .jsx
or .mjs
or .tsx
or whatever extension added to it.
You need to specify the actual URL you are importing.
import {student} from "./studentId.js";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.