3

Razzle is a server side rendering framework.

Here is the error:

/home/ajay/Ajay Nagotha/Projects/react-ssr-demo/luma-ssr/node_modules/react-bootstrap/esm/Container.js:1
import classNames from 'classnames';
^^^^^^

SyntaxError: Cannot use import statement outside a module
halfer
  • 19,824
  • 17
  • 99
  • 186
Ajay Nagotha
  • 41
  • 1
  • 1
  • 4
  • 2
    I wonder if searching for "Cannot use import statement outside a module" on Stack Overflow will give you the answer. – halfer Mar 01 '22 at 08:22
  • You can add { "type": "module" } in package.json to resolve this error, but you will likely run into other errors when trying to use modules that are not ES modules. You will need to use Bable or use all ES modules in your project. – kevintechie Mar 01 '22 at 09:33

1 Answers1

5

If you are using Visual Studio Code and let it automatically add the imports, it can use the incorrect path.

When I ran into this in my Typescript project, I had Code do the import, which creates the code

import Container from 'react-bootstrap/esm/Container';

The correct code doesn't have the esm path and should be

import Container from 'react-boostrap/Container';
Robert Myers
  • 51
  • 1
  • 2