0

I don't understand why my Google Cloud Run instance doesn't know what __dirname is

I have an expressjs server that has this in it:

import path from 'path';

const App = express()
    .get('/*', (_req, res) => {
      res.sendFile(path.join(__dirname, '.', 'index.html'));
    })

I get a compile error __dirname is not defined

Matt
  • 59,496
  • 7
  • 135
  • 138
PositiveGuy
  • 14,005
  • 18
  • 67
  • 121

1 Answers1

3

Rename to __dirname it should be point to path.join(__dirname, './src'), or you can create using const __dirname = path.resolve(path.dirname(''));

Geoffrey Hale
  • 9,339
  • 5
  • 39
  • 43