node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Error: Webpack compilation error

Open sivadgit opened this issue 2 years ago • 11 comments

We are using Redis cache in our Node JS Typescript Lambda API. Also we using webpack to run or build the API. While running the API we get Webpack compilation error . Please find the details below

ERROR in ./node_modules/redis/dist/index.js Module parse failed: Unexpected token (27:4) You may need an appropriate loader to handle this file type. | __exportStar(require("@node-redis/time-series"), exports);

Environment:

  • Node.js Version: nodejs14.x
  • Redis Server Version: 6.2.5
  • Node Redis Version:^4.0.4
  • Platform: Windows 10

sivadgit avatar Feb 26 '22 17:02 sivadgit

@sivadgit you can include your webpack configuration. Where do you run Lambda API? Why do you have to transpile the files? :thinking:

dannyk03 avatar Mar 05 '22 20:03 dannyk03

I'm facing a similar problem: image this is my webpack configuration:

module.exports = config => {
  return {
    ...config,
    externals: [
      {
        'aws-sdk': 'aws-sdk',
        'bufferutil': 'bufferutil',
        'utf-8-validate': 'utf-8-validate',
      },
    ],
    output: {
      ...config.output,
    },
  };
};

magallegos1996 avatar Jun 27 '22 23:06 magallegos1996

Why are you trying to use it with webpack?

leibale avatar Jun 28 '22 00:06 leibale

I'm facing a similar problem: image this is my webpack configuration:

module.exports = config => {
  return {
    ...config,
    externals: [
      {
        'aws-sdk': 'aws-sdk',
        'bufferutil': 'bufferutil',
        'utf-8-validate': 'utf-8-validate',
      },
    ],
    output: {
      ...config.output,
    },
  };
};

Please upgrade to latest version of Webpack and try again.

venkateshgshetty avatar Jun 29 '22 13:06 venkateshgshetty

My webpack version is 4.46.0. I am facing with the same problem. Which version webpack shall I use?

jamesliu668 avatar Aug 16 '22 13:08 jamesliu668

I'm facing a similar problem: image this is my webpack configuration:

module.exports = config => {
  return {
    ...config,
    externals: [
      {
        'aws-sdk': 'aws-sdk',
        'bufferutil': 'bufferutil',
        'utf-8-validate': 'utf-8-validate',
      },
    ],
    output: {
      ...config.output,
    },
  };
};

Do you solve the problem?

jamesliu668 avatar Aug 16 '22 13:08 jamesliu668

https://github.com/facebook/create-react-app/issues/9468#issuecomment-694191642 seems to have solved mine

xizhe-qiu avatar Nov 23 '22 03:11 xizhe-qiu

node v14 does not work with the latest version of node-redis. Please use node v12 or v16.

dannyk03 avatar Nov 23 '22 11:11 dannyk03

optional chaining is part of webpack5 (see: https://github.com/webpack/webpack/issues/10227#issuecomment-642734920) upgrading to webpack5 fixed for me

taemini avatar Jun 16 '23 05:06 taemini

i can't upgrade to webpack v5 with razzle

daniellizik avatar Aug 08 '23 10:08 daniellizik

Hi guys, I am facing the same problem, did you find a solution ? Nuxt 2.17.2 with Webpack 4, Babel 7, Node 20.10.0 Thanks

sbstnplcn avatar Jan 17 '24 15:01 sbstnplcn