I formatted my laptop and installed all fresh software on it. When I was trying to create a new SPFx solution, I was getting an error :
C:\Users\Hp\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`, `${prefix}/*/index.cjs`, `${prefix}/*/index.mjs`]),
^
TypeError: lookups.flatMap is not a function
at Environment.resolver.lookup (C:\Users\Hp\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70:27)
at init (C:\Users\Hp\AppData\Roaming\npm\node_modules\yo\lib\cli.js:130:7)
at pre (C:\Users\Hp\AppData\Roaming\npm\node_modules\yo\lib\cli.js:89:3)
at Object.<anonymous> (C:\Users\Hp\AppData\Roaming\npm\node_modules\yo\lib\cli.js:219:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
I tried to add new webpart in the existing solution but got same issue. Then I tried npm command :
npm list -g --depth=0I found that by mistake I installed wrong versions :
+-- @microsoft/generator-sharepoint@1.11.0
+-- gulp@4.0.2
+-- yo@4.0.0
The solution is uninstall the gulp & yeoman generator:
npm uninstall -g gulp
npm uninstall -g yo
Then install the correct version :
npm install -g gulp@3.9.1
npm install -g gulp@3.9.1
npm install -g yo@3.1.0
Now it is working fine.
Comments
Post a Comment