DEV Community

'Seun Somefun
'Seun Somefun

Posted on

HOW TO SOLVE THE NO VALID EXPORTS ERROR IN NODEJS.

Recently while running the sequelize-cli init command, I ran into an error. The error message was something like export not found.... I began to debug and even started placing console.log statements in the .sequelizerc file(lol). I had to open up several other projects I had done with sequelize to see if I was missing something, then checked the sequelize-cli docs if something had changed and everywhere but I still couldn't solve the problem. Funny enough the app was running with(npm run start:dev) so it got me more confused.

It happened again within the same week when I was trying to set up a nestjs project and this time around the same error was pointing to a file in the node_modules folder. The curiosity in me drove me to comment out some lines in the file it was pointing to but the error stayed the same and previous searches yielded nothing helpful till I stumbled upon something that talked about node versions. The problem according to this issue is that node odd versions seem to be broken so incase you stumble upon such a weird issue, here is how I solved it.

Solution

  1. Download nvm(node version manager). It helps to manage node versions locally and you can switch between various node LTS(Long Term Support) versions using nvm.

  2. Then install a node version(nvm install <version number>) with an even number(v13.14/v14). Most likely, you would currently have an odd number node version(v9.7/v11.15/v13.9) if you check with node -v.

  3. Switch to the new version you just installed with nvm use <version number> e.g nvm use 10.

  4. Close the project on VSCode and reopen it again then run the command you were trying to run initially and it should work without errors now. If you check the node version now, you will see it's the newly installed version you are currently running on. If you still have any issues, you could delete the node_modules and package-lock.json then run npm install again.

This article talks about nvm in more detail.

Thanks for coming to my Ted Talk.

Top comments (0)