Recently built a new VM for the SPFx development and as part of that installed the node and gulp. After creating the first WebPart and when trying to build using the gulp was getting the below exception. primordials is not defined
at fs.js:35:5
at req_ (C:\WORK\SourceCode\spfxsolution\node_modules\natives\index.js:143:24)
at Object.req [as require] (C:\WORK\SourceCode\spfxsolution\node_modules\natives\index.js:55:10)
at Object.
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
Then realized that the node version and gulp version will have a mismatch. Verified my node and gulp versions.
λ node –version
v12.16.3
C:\WORK\SourceCode\spfxsolution
λ gulp –version
CLI version: 2.2.0
Local version: 3.9.1
Either, I need to upgrade the gulp version or downgrade the node version.
Tried various commands to do this and at least for me, none of the things were working. At last, uninstalled the node and again reinstalled through the msi itself. We can uninstall from appwiz.cpl as any other application.
You can download the version 10.20.1 from the below link.
https://nodejs.org/download/release/v10.20.1/
After that, the gulp commands started working.
Happy Coding
Sathish Nadarajan
Leave a comment