我正在尝试为Sharepoint Online构建我的第一个本地化 SPFX WebPart。我在de-de.js
文件夹中添加了另一种语言loc
,现在我想通过将`“ debugLocale”属性添加到write-manifest.json
来在调试中使用新的语言。它:
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->",
"debugLocale": "de-de"
}
检查official instructions of Microsoft和检查JSON sheme of the write-manifest.json显示应该编译,但是当我gulp serve
返回时:
Build target: DEBUG
./node_modules/@microsoft/node-core-library/lib/JsonSchema.js:178
throw new Error(prefix + os.EOL +
^
Error: JSON validation failed:
./config/write-manifests.json
Error: #/ (Defines configuration options for the...)
Additional properties not allowed: debugLocale
at validateObjectWithCallback (./node_modules/@microsoft/node-core-library/lib/JsonSchema.js:178:19)
at JsonSchema.validateObjectWithCallback (./node_modules/@microsoft/node-core-library/lib/JsonSchema.js:193:13)
at JsonSchema.validateObject (./node_modules/@microsoft/node-core-library/lib/JsonSchema.js:175:14)
at WriteManifestsTask._readConfigFile (./node_modules/@microsoft/gulp-core-build/lib/tasks/GulpTask.js:311:28)
at WriteManifestsTask.onRegister (./node_modules/@microsoft/gulp-core-build/lib/tasks/GulpTask.js:87:32)
at Object.initialize (./node_modules/@microsoft/gulp-core-build/lib/index.js:299:24)
at SPWebBuildRig.initialize (./node_modules/@microsoft/sp-build-common/lib/BuildRig.js:61:19)
at SPWebBuildRig.initialize (./node_modules/@microsoft/sp-build-common/lib/SPBuildRig.js:29:15)
at SPWebBuildRig.initialize (./node_modules/@microsoft/sp-build-web/lib/SPWebBuildRig.js:15:15)
at Object.exports.initialize (./node_modules/@microsoft/sp-build-web/lib/index.js:23:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world@0.0.1 start: `gulp serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/2019-01-09T16_43_53_070Z-debug.log
我该如何解决这个问题?
答案 0 :(得分:2)
我刚刚尝试过,它可以在我的设置中正常工作。
yo @microsoft/sharepoint
和默认选项(使用React作为Javascript框架)创建的webpart de-de.js
文件添加到loc
文件夹并更改了值,因此我可以看到它确实是在获取正确的文件"debugLocale": "de-de"
添加到了write-manifests.json
gulp serve
de-de.js
我的版本:
但是,一旦我将@microsoft/sharepoint
生成器更新为最新版本1.7.1,它便停止工作。该问题似乎是从1.6.0版开始出现的
解决方法是使用--locale
之类的gulp serve --locale=de-de
参数运行它,或使用旧版本:
npm uninstall @microsoft/generator-sharepoint -g
npm install @microsoft/generator-sharepoint@1.5.1 -g
答案 1 :(得分:2)
在1.5和1.6之间,构建任务似乎已更改。我已经用1.6+确认了这个问题。
如果将write-manfiest.json的“ debugLocale”修改为“ buildSingleLocale”,一切将按预期进行。我认为文档和架构可能已过时。
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->",
"buildSingleLocale": "de-de"
}