Windows is never developer friendly.
However, today I tried to setup a basic React
project from scratch on my Windows machine.
This machine already had node
and npm
installed. But the versions were outdated and were not compatible with the webpack
configuration for Windows 10.
I had to update node
and npm
, and it was not as simple as I had thought it would be.
fsevents node-pre-gyp cannot find python windows
This thread https://github.com/webpack/webpack/issues/1435 pointed out about a bug in older npm
version and that it was fixed in npm @3.10.10
.
npm
npm install npm@latest -g
npm -v
still pointed to the old version, even though I restarted the command terminal.
The problem being npm PATH
was missing from the environment variable.
Since there was already node
installed, I had to set the npm PATH
before node PATH
.
Updating npm
helped me to install webpack
and webpack-dev-server
. When i tried running the React
app using npm run dev
, I had an eslint
error. The project was configured to use eslint
.
use of const in strict mode
This thread http://stackoverflow.com/questions/22603078/syntaxerror-use-of-const-in-strict-mode pointed out that the above error would disappear on upgrading node to 4.x or higher version.
I needed nvm
, to upgrade node to the latest version.
This link had the nvm
installer for Windows https://github.com/coreybutler/nvm-windows
The above installer required me to uninstall any existing versions of node
and delete the existing npm
install location C:\Users\<user>\AppData\Roaming\npm
Updating npm
before updating node
was not useful, but it was a good learning lesson to know how to update npm
.
With nvm
, I could now install the latest version of node
using this command nvm install latest
.
To use this latest version, I ran nvm use <latest-version>
With this, I successfully compiled a React project from scratch on a Windows machine!