java - 安装 @microsoft/sharepoint 生成器时出现 Yeoman SPFx 问题
问题描述
我正在尝试学习如何使用 SPFx,但是在运行yo @microsoft/sharepoint
.
运行时出现以下错误yo @microsoft/sharepoint
:
Error @microsoft/sharepoint
You don't seem to have a generator with the name “@microsoft/sharepoint” installed.
But help is on the way:
You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/.
Install them with npm install @microsoft/generator-sharepoint.
To see all your installed generators run yo --generators. Adding the --help option will also show subgenerators.
If yo cannot find the generator, run yo doctor to troubleshoot your system.
我试过运行npm install @microsoft/generator-sharepoint -g
,但这并不能解决上述错误。还值得注意的是,我在运行 install generator 命令时遇到了一堆错误:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@microsoft/generator-sharepoint@1.13.0',
npm WARN EBADENGINE required: { node: '>=12.13.0 <13.0.0 || >=14.15.0 <15.0.0' },
npm WARN EBADENGINE current: { node: 'v16.13.0', npm: '8.1.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@microsoft/sp-module-interfaces@1.13.0',
npm WARN EBADENGINE required: { node: '>=12.13.0 <13.0.0 || >=14.15.0 <15.0.0' },
npm WARN EBADENGINE current: { node: 'v16.13.0', npm: '8.1.0' }
npm WARN EBADENGINE }
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies
.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies
.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams
API instead.
npm WARN deprecated uuid@3.1.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain
circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain
circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain
circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain
circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain
circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @opentelemetry/types@0.2.0: Package renamed to @opentelemetry/api, see https://github.com/open-telem
etry/opentelemetry-js
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please
upgrade asap.
npm ERR! code 1
npm ERR! path C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharepoint\node_modules\node-sas
s
npm ERR! command failed
npm ERR! command C:\windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\gene
rator-sharepoint\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= - -libsass_cflags= --libsass_ldfl
ags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli 'C:\\Users\\%username%\\AppData\\Roaming\\npm\\node_modules\\@microsoft\\generator- sharepoint\\n
ode_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsof
t\generator-sharepoint\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sha
repoint\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sha
repoint\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharep
oint\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharep
oint\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharep
oint\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsof
t\generator-sharepoint\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sha
repoint\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sha
repoint\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharep
oint\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharep
oint\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator-sharep
oint\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Program Files\Python310\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Program Files\Python310\python.EXE -c import sys; print "%s.%s.%s" % s
ys.version_info[:3];
npm ERR! gyp ERR! stack File "<string>", line 1
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:397:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.14393
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\%username%\\AppData\\Roaming\\npm\\node_modu
les\\@microsoft\\generator-sharepoint\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext="
"--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\%username%\AppData\Roaming\npm\node_modules\@microsoft\generator- sharepoint\node_modules\
node-sass
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\%username%\AppData\Local\npm-cache\_logs\2021-11-12T03_25_38_209Z-debug.log
有人可以帮我解决这个问题吗?我不确定是什么导致了@microsoft/sharepoint 生成器安装问题,但似乎有些东西阻止了它正确安装。
任何帮助是极大的赞赏。
非常感谢,
亚历克斯。
解决方案
原来问题是当我需要使用受支持的版本 (v14.15.0) 时,我使用的是最新版本的 Node.js (v16.13.0)
推荐阅读
- django - Many_to_many --> FieldError: Related Field got invalid lookup: contains
- javascript - 在不复制的情况下在 Blob 和 ArrayBuffers 之间转换?
- node.js - npm dev:start 不运行
- visual-studio-code - 我可以将 VS Code 中的“跳转到符号”调整为“跳转到方法/函数/类”吗?
- debugging - Coldfusion cflog 没有向日志文件添加任何文本
- c - 将元素动态添加到数组 C
- javascript - 如何将数组中的唯一值设置为“0”而不是未定义?(Javascript)
- c# - Azure 应用服务多容器 - 对内部容器的 http 请求(docker compose)
- java - 从命令行编译和运行 Java
- flutter - Flutter - 未处理的异常:NoSuchMethodError:在 null 上调用了方法“验证”