Rafael Trevisan
Rafael Trevisan

Reputation: 1

When starting the project, reactstrap presents an error when importing the lib

Error console /node_modules/reactstrap/lib/index.js:1 import _Container from './Container'; ^^^^^^

SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at Object.reactstrap (/home/rafael/Documentos/dev/academy/.next/server/pages/_app.js:715:18) at webpack_require (/home/rafael/Documentos/dev/academy/.next/server/webpack-runtime.js:33:42)

Node.js v18.15.0 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. (https://i.sstatic.net/W7GGd.png)

Index.js for reactstrap
import _Container from './Container';
export { _Container as Container };
import _Row from './Row';
export { _Row as Row };
import _Col from './Col';
export { _Col as Col };
import _Navbar from './Navbar';
export { _Navbar as Navbar };
import _NavbarBrand from './NavbarBrand';
export { _NavbarBrand as NavbarBrand };
import _NavbarText from './NavbarText';
export { _NavbarText as NavbarText };
import _NavbarToggler from './NavbarToggler';
export { _NavbarToggler as NavbarToggler };
import _Nav from './Nav';
export { _Nav as Nav };
import _NavItem from './NavItem';
export { _NavItem as NavItem };
import _NavLink from './NavLink';
export { _NavLink as NavLink };

(https://i.sstatic.net/fInzi.png)

I already tried to reinstall reactstrap but it didn't work

Upvotes: -1

Views: 450

Answers (2)

Thomas Albuquerque
Thomas Albuquerque

Reputation: 11

I followed the instruction posted by Md. Minhaz Ahamed, but in my case I changed from version 9.1.8 of reactstrap to version 9.1.6 and it worked.

Upvotes: 1

Md Minhaz Ahamed
Md Minhaz Ahamed

Reputation: 459

I encountered the same issue. After a lot of tries on different things. I got a solution after changing the reactstrap version. So far with two version it worked

"reactstrap": "^10.0.1-release-v10.0.0-c659629.0",
 or
"reactstrap": "^8.10.1",

I decided to stay with 10.0.1-release-v10.0.0-c659629.0 for now and its working okay

Upvotes: 0

Related Questions