找不到模块:无法解析“readline”

DO *_* IT 5 javascript node.js aws-sdk amazon-athena

我遇到Module not found: Can't resolve 'readline'已安装的 NPM 包错误,并且该包似乎存在于 node_modules 文件夹中。错误的地方:

错误的地方

module "c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index"
Could not find a declaration file for module 'athena-express'. 'c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index.js' implicitly has an 'any' type.
  Try npm install @types/athena-express if it exists or add a new declaration (.d.ts) file containing declare module athena-express';ts(7016) 
Run Code Online (Sandbox Code Playgroud)

尝试导入并需要该模块,但仍然有相同的错误。使用“创建反应应用程序”来创建反应应用程序。也尝试了上面的一切。下面的代码尝试使用 Athena 查询 s3。

module "c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index"
Could not find a declaration file for module 'athena-express'. 'c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index.js' implicitly has an 'any' type.
  Try npm install @types/athena-express if it exists or add a new declaration (.d.ts) file containing declare module athena-express';ts(7016) 
Run Code Online (Sandbox Code Playgroud)

Expect 工作时没有错误,但有错误

DO *_* IT 4

readline 问题可以通过 npm 安装 readline 来解决。这似乎是 create-react-app 的常见问题。主要是因为 create-react-app 适用于基于浏览器的前端应用程序,而 athena-express 是一个中间件,可以将您的前端与 Amazon Athena 连接起来。如果在前端安装了 athena-express,最终会暴露包含您的密钥和访问密钥的 aws 对象。

最好的办法是创建一个简单的 node.js 应用程序作为中间件(独立应用程序或 AWS Lambda),以使用 aws 对象初始化 athena-express,以便您的凭证安全。然后,您可以从浏览器 React 应用程序中将 athena-express 作为 API 调用。

  • 我安装了它,然后看到错误“TypeError:“原始”参数必须是 Function 类型”。 (5认同)