2

I am having an issue when I am trying to use the aws-sdk v3.
I am confident it is because of the optional chaining used in this node module file.

ERROR in ./node_modules/@aws-sdk/signature-v4/dist-es/getCanonicalHeaders.js 10:30
Module parse failed: Unexpected token (10:30)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|         const canonicalHeaderName = headerName.toLowerCase();
|         if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS ||
>             unsignableHeaders?.has(canonicalHeaderName) ||
|             PROXY_HEADER_PATTERN.test(canonicalHeaderName) ||
|             SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
 @ ./node_modules/@aws-sdk/signature-v4/dist-es/index.js 2:0-60 2:0-60

I am using Babel 7, Webpack 4, and Node 14.

I've added @babel/plugin-proposal-optional-chaining to my babel.config file below:

module.exports = function (api) {
  api.cache(true);

  const presets = ['@babel/preset-env', '@babel/preset-react'];
  const plugins = [
    ['@babel/plugin-proposal-nullish-coalescing-operator'],
    ['@babel/plugin-proposal-optional-chaining'],
  ];

  return {
    presets,
    plugins
  };
};

I've even tried adding @babel/plugin-proposal-optional-chaining to my webpack.config.js file:

        {
          test: /\.(js|jsx|es)$/,
          use: [
            'thread-loader',
            {
              loader: 'babel-loader',
              options: {
                plugins: [
                  '@babel/plugin-proposal-nullish-coalescing-operator',
                  '@babel/plugin-proposal-optional-chaining'
                ],
                presets: ['@babel/preset-react', '@babel/preset-env']
              }
            }
          ],
          exclude: '/node_modules/',
        },
2
  • What version of Node are you trying to run this all under? Babel etc. won't generally transpile dependencies. Commented Apr 27, 2023 at 21:19
  • I am using v14.6.0 Commented Apr 28, 2023 at 14:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.