Typescript : require statement not part of an import statement

后端 未结 4 2419
我寻月下人不归
我寻月下人不归 2021-02-18 13:10

Typescript version 2.2.2

I wrote this require in my UserRoutzr.ts

const users =  require(path.join(process.cwd() + \"/data\"));

4条回答
  •  天命终不由人
    2021-02-18 13:36

    Needed to use provide plugin, yet neither require nor dynamic imports worked for me, this construct helped though:

    module.exports = {
      // ..
      chainWebpack: (config) => {
        config.plugin('provide').use(require('webpack').ProvidePlugin, [
          // ..
        ])
      },
    

提交回复
热议问题