Node, nvm and npm

Windows is never developer friendly.

However, today I tried to setup a basic Reactproject from scratch on my Windows machine.

This machine already had nodeand npminstalled. But the versions were outdated and were not compatible with the webpackconfiguration for Windows 10.

I had to update nodeand npm, and it was not as simple as I had thought it would be.


Error #1

fsevents node-pre-gyp cannot find python windows

Solution #1

This thread https://github.com/webpack/webpack/issues/1435 pointed out about a bug in older npmversion and that it was fixed in npm @3.10.10.

Update 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 nodeinstalled, I had to set the npm PATH before node PATH.


Updating npmhelped me to install webpackand webpack-dev-server. When i tried running the Reactapp using npm run dev, I had an eslinterror. The project was configured to use eslint.


Error #2

use of const in strict mode

Solution #2

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.

Update node

I needed nvm, to upgrade node to the latest version.

This link had the nvminstaller for Windows https://github.com/coreybutler/nvm-windows

The above installer required me to uninstall any existing versions of nodeand delete the existing npminstall location C:\Users\<user>\AppData\Roaming\npm

Updating npmbefore updating nodewas 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 nodeusing 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!

results for ""

    No results matching ""