首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Compilation参数必须是office外接程序中编译错误的实例

Compilation参数必须是office外接程序中编译错误的实例
EN

Stack Overflow用户
提问于 2021-11-05 10:10:32
回答 1查看 590关注 0票数 0

我是office插件开发的新手,但在我们的组织中有一个项目。安装完package.json文件中提到的所有依赖项后,当我尝试运行'npm run dev-server‘时,得到以下错误:

代码语言:javascript
复制
c:\git\sample-project\ui-addin>npm run dev-server

> ui-addin@1.0.0 dev-server c:\git\sample-project\ui-addin
> webpack-dev-server --mode development

You already have trusted access to https://localhost.
Certificate: C:\Users\Manish.Kumar\.office-addin-dev-certs\localhost.crt
Key: C:\Users\Manish.Kumar\.office-addin-dev-certs\localhost.key
i 「wds」: Project is running at https://127.0.0.1:3000/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from c:\git\sample-project\ui-addin
(node:19272) UnhandledPromiseRejectionWarning: TypeError: The 'compilation' argument must be an instance of Compilation
at Function.getCompilationHooks (c:\git\sample-project\ui-addin\node_modules\custom-functions-metadata-plugin\node_modules\webpack\lib\NormalModule.js:207:10)
at c:\git\sample-project\ui-addin\node_modules\custom-functions-metadata-plugin\lib\customfunctionsplugin.js:41:36
at SyncHook.eval [as call] (eval at create (c:\git\sample-project\ui-addin\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
at SyncHook.lazyCompileHook (c:\git\sample-project\ui-addin\node_modules\webpack\node_modules\tapable\lib\Hook.js:154:20)
at Compiler.newCompilation (c:\git\sample-project\ui-addin\node_modules\webpack\lib\Compiler.js:631:26)
at c:\git\sample-project\ui-addin\node_modules\webpack\lib\Compiler.js:667:29
at eval (eval at create (c:\git\sample-project\ui-addin\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:14:1)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19272) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:19272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我使用'npm ls webpack‘验证了安装的webpack版本,并使其完全相同。但目前还不走运。这个相同的应用程序正在另一个用户的机器上运行文件,他可以运行插件,但我不知道为什么我会得到这个错误。

我的package.json文件:

代码语言:javascript
复制
{
"name": "ui-addin",
"version": "1.0.0",
"license": "MIT",
"config": {
    "app-to-debug": "excel",
    "app-type-to-debug": "desktop",
    "dev-server-port": 3000,
    "source-bundle-url-path": "index.win32"
},
"scripts": {
    "build": "webpack -p --mode production --https false",
    "build:dev": "webpack --mode development --https false",
    "dev-server": "webpack-dev-server --mode development",
    "lint": "office-addin-lint check",
    "lint:fix": "office-addin-lint fix",
    "prettier": "office-addin-lint prettier",
    "start": "office-addin-debugging start manifest-local.xml",
    "start:desktop": "office-addin-dev-settings webview manifest-local-sr.xml edge && office-addin-debugging start manifest-local-sr.xml desktop",
    "start:desktop-ie-webview": "office-addin-dev-settings webview manifest-local.xml edge && office-addin-debugging start manifest-local.xml desktop",
    "start:no-shared-runtime:desktop": "office-addin-debugging start manifest-local.xml desktop",
    "start:ci:desktop": "office-addin-debugging start manifest-ci.xml desktop",
    "sideload-local": "office-toolbox sideload -m manifest-local.xml -a Excel",
    "start:web": "office-addin-debugging start manifest-local.xml web",
    "stop": "office-addin-debugging stop manifest-local.xml",
    "stop:ci": "office-addin-debugging stop manifest-ci.xml",
    "validate": "office-addin-manifest validate manifest-local-sr.xml",
    "watch": "webpack --mode development --watch",
    "test": "mocha -r ts-node/register test/*.ts",
    "clear-all-cached-plugin": "rimraf \"%LOCALAPPDATA%\\Microsoft\\Office\\16.0\\Wef\""
},
"dependencies": {
    "@types/jquery": "~3.5.0"
},
"devDependencies": {
    "@babel/core": "~7.10.3",
    "@babel/polyfill": "~7.10.1",
    "@babel/preset-env": "~7.10.3",
    "@openapitools/openapi-generator-cli-ihsmarkit": "~4.3.4",
    "@types/custom-functions-runtime": "~1.5.1",
    "@types/find-process": "~1.2.0",
    "@types/mocha": "~7.0.2",
    "@types/node": "~14.0.14",
    "@types/office-js": "~1.0.111",
    "@types/office-runtime": "~1.0.14",
    "babel-loader": "~8.0.6",
    "clean-webpack-plugin": "~3.0.0",
    "copy-webpack-plugin": "~5.1.1",
    "custom-functions-metadata-plugin": "~1.0.30",
    "eslint-config-office-addins": "~1.0.15",
    "file-loader": "~4.2.0",
    "html-loader": "~0.5.5",
    "html-webpack-plugin": "~3.2.0",
    "merge-jsons-webpack-plugin": "~1.0.21",
    "mocha": "~8.0.1",
    "office-addin-cli": "~1.0.10",
    "office-addin-debugging": "~3.0.31",
    "office-addin-dev-certs": "~1.5.2",
    "office-addin-dev-settings": "~1.8.3",
    "office-addin-lint": "~1.0.23",
    "office-addin-manifest": "~1.5.4",
    "office-addin-prettier-config": "~1.0.12",
    "office-addin-test-helpers": "~1.0.20",
    "office-addin-test-server": "~1.0.27",
    "prettier": "~1.19.1",
    "rimraf": "~3.0.2",
    "source-map-loader": "~0.2.4",
    "ts-loader": "~6.1.0",
    "ts-node": "~8.10.2",
    "typescript": "~3.9.5",
    "webpack": "~4.43.0",
    "webpack-cli": "~3.3.12",
    "webpack-dev-server": "~3.11.0"
},
"prettier": "office-addin-prettier-config"

}

EN

回答 1

Stack Overflow用户

发布于 2021-11-10 16:35:50

这个问题与Windows、Powershell以及区分大小写的方式有关。我知道您使用Powershell,因为如果您只是打开一个命令提示符,就不会出现这个问题。(这可能在一定程度上解释了为什么它在同事的工作站上工作。)

使用命令提示符或找到目录的确切大小写(例如,使用资源管理器),并在Powershell中使用大小写。

上面显示的路径是:c:\git\sample-project\ui-addin

作为演示,我将在本地命令提示符下创建与您相同的目录:

代码语言:javascript
复制
C:\>mkdir git\sample-project\ui-addin
C:\>cd git\sample-project\ui-addin
C:\git\sample-project\ui-addin>

让我们转到Powershell中的同一目录:

代码语言:javascript
复制
PS C:\> cd Git\Sample-Project\Ui-ADDIN\
PS C:\Git\Sample-Project\Ui-ADDIN>

哈?Powershell将严格遵守我使用的任何用例,但也会维护它!我对这个问题的挖掘还不够深入,无法真正理解背后发生了什么,但不管是什么,对npm和Webpack来说,有问题就足够了。

不管它有什么价值,命令shell将不会接受除原始情况以外的任何情况:

代码语言:javascript
复制
C:\>cd Git\Sample-PROJECT\UI-addin\
C:\git\sample-project\ui-addin>

虽然许多资源帮助我解决了这个问题,但this Github issue帮助我理解并解决了它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69851599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档