簡體   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