Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use import statement outside a module #591

Open
boybeak opened this issue Mar 22, 2023 · 1 comment
Open

Cannot use import statement outside a module #591

boybeak opened this issue Mar 22, 2023 · 1 comment

Comments

@boybeak
Copy link

boybeak commented Mar 22, 2023

I want to import some public functions from another js file. But an error Cannot use import statement outside a module happened. How to fix this?

@Saikiran8844
Copy link

Saikiran8844 commented Jul 20, 2024

Hi @boybeak find the examples below
you can use the reference of the file
JavaScript
const myModule = require('./otherFile');

JavaScript1

export function greet(name) {
  return `Hello, ${name}!`;
}

JavaScript2

import { greet } from './first.js';

console.log(greet('World'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants