我是Yeoman的新手,所以任何帮助都会非常有用。
尝试使用Yeoman SharePoint Framework webpart生成器时,出现以下错误:
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)
答案 0 :(得分:0)
您需要检查的事情:
1)确保您使用的是Node.js LTS版本。 如果不确定,请卸载Node js,然后从此处下载Node v6.11
2)确保您的NPM版本是3.x. SPFx目前与NPM 5不兼容。
您可以通过在命令行中运行npm -v
命令来检查它。
如果是版本5,您可以通过运行以下命令降级它:
npm install -g npm3
3)完成后,您可以安装spfx的最新yeoman模板,如下所示:
npm install @microsoft/generator-sharepoint@latest -g
4)之后,您可以运行yo @microsoft/sharepoint
命令来创建SPFx webpart
答案 1 :(得分:0)
以下列方式复制。
在步骤2中,必须将所有隐藏文件移动到子文件夹。 无论如何,此问题的解决方法是使用不相关的全新文件夹,如Parent2。
父(Sub1,Sub2),Parent2