Webstorm cannot use import to report an error?

/ / index.js

const {query} = require("./sql");
export async function getUser(name){
 let sql = `select name,password from users whername="${name}" `;
  let user = await query(sql)
  return user;
}

/ / server.js

import {getUser} from "./index.js"

error

C:\Users\love4\WebstormProjects\shoppingList\koa\server.js:4
import {getUser} from "./index.js"
^^^^^^

SyntaxError: Unexpected token import

it can be used normally if you use module.exports and require.
is it necessary to configure babel? I didn"t seem to have a problem before I set up ES6 in webstorm

Mar.07,2021

  1. use require;
  2. needs to be used in conjunction with babel.

your server.js is for nodejs, isn't it? how can you use import? Use require.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f276-2c469.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f276-2c469.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?