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

ReferenceError: __dirname is not defined #24

Open
dcjayasuriya2020 opened this issue Jan 10, 2021 · 2 comments
Open

ReferenceError: __dirname is not defined #24

dcjayasuriya2020 opened this issue Jan 10, 2021 · 2 comments

Comments

@dcjayasuriya2020
Copy link

code in the datafile is lib.baseDir = path.join(__dirname, '/../.data/');
in git bash it indicates when run for test err,

$ node index.js
file:///E:/Learn/lib/data.js:15
lib.baseDir = path.join(__dirname, '/../.data/');
                        ^

 ReferenceError: __dirname is not defined

How to get clear on this?

@xuych
Copy link

xuych commented May 10, 2021

const __dirname = path.resolve();

@Luis-Enrique-Mora
Copy link

import path from 'path';
import { fileURLToPath } from 'url';
// data path
const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );
//* Base directory of the data folder
const templateDir = path.join( __dirname, '/../.data/' );

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

3 participants