Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  153] [ 6]  / answers: 1 / hits: 9366  / 4 Years ago, mon, november 23, 2020, 12:00:00

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


More From » node.js

 Answers
3

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


[#2258] Tuesday, November 17, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isaacvalentinn

Total Points: 325
Total Questions: 120
Total Answers: 131

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
isaacvalentinn questions
;