Ajay Nagotha
Ajay Nagotha

Reputation: 41

I am getting the error "Cannot use import statement outside a module" when I run my React Razzle app

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

Upvotes: 3

Views: 11432

Answers (1)

Robert Myers
Robert Myers

Reputation: 61

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';

Upvotes: 6

Related Questions