I'm new to Yeoman so any help would really be useful.
When attempting to use the Yeoman SharePoint Framework webpart generator I get the following error:
events.js:160
throw er; // Unhandled 'error' event
^
Error: Cannot find "package.json" file required by this generator
at WebpartGenerator.get [as packageJson] (/usr/local/lib/node_modules/@microsoft/generator-sharepoint/lib/common/BaseGenerator.js:45:23)
at WebpartGenerator.BaseGenerator.ensureDependencyGroup (/usr/local/lib/node_modules/@microsoft/generator-sharepoint/lib/common/BaseGenerator.js:96:18)
at WebpartGenerator.BaseComponentGenerator.configuring (/usr/local/lib/node_modules/@microsoft/generator-sharepoint/lib/generators/component/BaseComponentGenerator.js:95:14)
at WebpartGenerator.configuring (/usr/local/lib/node_modules/@microsoft/generator-sharepoint/lib/generators/webpart/index.js:43:38)
at Object.<anonymous> (/usr/local/lib/node_modules/@microsoft/generator-sharepoint/node_modules/yeoman-generator/lib/index.js:408:23)
at /usr/local/lib/node_modules/@microsoft/generator-sharepoint/node_modules/run-async/index.js:25:25
at /usr/local/lib/node_modules/@microsoft/generator-sharepoint/node_modules/run-async/index.js:24:19
at /usr/local/lib/node_modules/@microsoft/generator-sharepoint/node_modules/yeoman-generator/lib/index.js:409:9
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
Couple of things that you need to check:
1) Ensure that you are using the Node.js LTS version. If unsure, uninstall the Node js, and download it from here - Node v6.11
2) Ensure that your NPM version is 3.x. SPFx is currently not compatible with NPM 5.
You can check that by running the
npm -v
command in the command line.If its version 5, you can downgrade it by running the below command:
3) Once done, you can install the latest yeoman template of spfx as below:
4) After that, you can run the
yo @microsoft/sharepoint
command to create SPFx webpart