reactjscra

Failed to Compile Error on npm run start - CRA - Need a solution without reinstalling NODE


I have a project bootstrapped using Create React App (CRA) with templates provided by ReactStrap Library. The trouble is in my windows system with the exact same node version npm run start works well but on my Macbook pro it failed with error: See below errors details:

Failed to compile.

./src/styles/reduction.scss (./node_modules/css-loader??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-3!./src/styles/reduction.scss) Error: Missing binding /Users/ganesh/Desktop/Juego Projects/2.4 Dream Ludo/0.0 Sourcecode/manojshetty-server-dreamludo/dream-ludo-cms/node_modules/node-sass/vendor/darwin-x64-72/binding.node Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 12.x Found bindings for the following environments: - OS X 64-bit with Node.js 10.x This usually happens because your environment has changed since running npm install. Run npm rebuild node-sass to download the binding for your current environment.

Below are the things that i tried. The way i got it working is with uninstalling NODE and installing an older version. But i cant keep doing it all the time.

Any solutions? I intend to check this further tonight but for now having to work with multiple codebases doesnt really help in having to install 1 node version at a time. it is also time consuming.


Solution

  • This happened with me too in the past. Heres what i had done to get it resolved. see if it works for you. The thing is you need multiple versions of node running in the same machine with option to switch or mark 1 as default while having others too. The best option for this is to install NVM See this LINK!

    once done, you go to the root of your project. Better start clean. So remove the existing node_modules folder(and its subfolders), Remove the package-lock.json

    now change to node version 10 by doing nvm use 10 (it will tell you if you dont have node 10 installed, follow the on screen steps)

    now do npm install followed by running the project. This should work now.

    Once you are done, and want to run another project. Go to the root of that project and then do the same nvm use then run the project.

    good luck