Webpack can not use __dirname?

后端 未结 1 362
抹茶落季
抹茶落季 2021-01-18 03:05

I am trying to use node-postgres to hook my app up to Postgres. The code I use is:

import React from \'react\';
import pg from \'pg\';
import fs from \'fs\';         


        
相关标签:
1条回答
  • 2021-01-18 03:22

    In that case, add this to your webpack config:

    {
      node: {
        __dirname: true
      }
    }
    

    This will tell webpack to replace __dirname instances with the path of the module. This path relative to context

    0 讨论(0)
提交回复
热议问题