繁体   English   中英

使用带有 Excel JS 插件的第三方节点模块

[英]Using third-party node modules with Excel JS Add-In

我正在尝试创建一个 Excel 插件来生成自定义函数(又名 UDF)以从使用 OAUTH1 三步过程收集数据的 web 数据源中提取数据。 它类似于 OAUTH2 进程,但可以连接到本地主机。

我有可以在 Node.JS 上运行的代码来授权 OUATH1 进程。 它使用以下代码:

`var papaParse = require('papaparse');`
`const express = require("express");`
`const {nanoid} = require("nanoid");`
`const open = require("open");`
`const crypto = require('crypto');`
`const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));`

Excel 插件是否在浏览器空间中运行,因此无法访问 express?

我不确定我是否了解如何在 Excel 加载项项目中使用这些库。 在更糟糕的情况下,我可以要求用户插入令牌并删除对 express 的要求,但我仍然需要其他库。

我使用“npm install papaparse”、“npm install express”等将每个库添加到项目中,并希望能够访问这些库并在项目中使用它们。

以下是我在代码中使用上述库收到的错误。

`WARNING in ./node_modules/express/lib/view.js 81:13-25`
`Critical dependency: the request of a dependency is an expression`
`@ ./node_modules/express/lib/application.js 22:11-28`
`@ ./node_modules/express/lib/express.js 18:12-36`
`@ ./node_modules/express/index.js 11:0-41`
`@ ./src/functions/functions.js 49:14-32`

`WARNING in ./node_modules/on-finished/index.js 207:11-33`
`Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\EricLevy\OneDrive - Meridian Business Services\mb_ns_connector_test\mb_ns_connector_test\node_modules\on-finished'`
`@ ./node_modules/express/lib/response.js 23:17-39`
`@ ./node_modules/express/lib/express.js 22:10-31`
`@ ./node_modules/express/index.js 11:0-41`
`@ ./src/functions/functions.js 49:14-32`

`WARNING in ./node_modules/raw-body/index.js 302:11-33`
`Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\EricLevy\OneDrive - Meridian Business Services\mb_ns_connector_test\mb_ns_connector_test\node_modules\raw-body'`
`@ ./node_modules/body-parser/lib/read.js 16:14-33`
`@ ./node_modules/body-parser/lib/types/raw.js 15:11-29`
`@ ./node_modules/body-parser/index.js 144:15-41`
`@ ./node_modules/express/lib/express.js 15:17-39`
`@ ./node_modules/express/index.js 11:0-41`
`@ ./src/functions/functions.js 49:14-32`

`3 warnings have detailed information that is not shown.`
`Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`

`ERROR in ./src/functions/functions.js 56:13-30`
`Module not found: Error: Can't resolve 'crypto' in 'C:\Users\EricLevy\OneDrive - Meridian Business Services\mb_ns_connector_test\mb_ns_connector_test\src\functions'`

Office web 加载项在 web 浏览器(嵌入式)中运行。 因此,您可以将其视为ExpressJS没有任何意义的客户端应用程序。 ExpressJS用于服务器端(例如,创建 API)。

Excel 插件是一个 web 应用程序,因此它同时具有服务器端和客户端。 一个express服务器在服务器端运行在Node.js。 任何可以在 Node.js 中使用的库也可以在 Excel 插件中使用。

您问题中的错误与您将 web 应用程序显示为 Excel 加载项这一事实没有任何关系。 考虑编辑您的问题和标题(和标签)以删除对加载项的提及。 Node.js 和快递专家如果认为是关于 Excel 加载项,他们可能会忽略该问题。

我建议您首先让您的 web 应用程序在浏览器中运行。 只需省略调用 Office.js 的 JavaScript。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM