小编Sul*_*ahi的帖子

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

我的项目有两个文件夹

  1. 客户
  2. 服务器

客户端和服务器都运行,但有时当我访问任何页面时在客户端上运行,因此在终端上以下错误显示了如何修复这些错误

wait  - compiling... 
warn  -

../server/node_modules/mongodb/lib/core/auth/mongodb_aws.js 
Module not found: Can't resolve 'aws4' in 'C:\Users\MyName\Desktop\Project\server\node_modules\mongodb\lib\core\auth'

../server/node_modules/mongodb/lib/operations/connect.js
Module not found: Can't resolve 'mongodb-client-encryption' in 'C:\Users\MyName\Desktop\Project\server\node_modules\mongodb\lib\operations'
 
../server/node_modules/mongoose/lib/index.js
Critical dependency: the request of a dependency is an expression

../server/node_modules/require_optional/index.js
Critical dependency: the request of a dependency is an expression
 
../server/node_modules/require_optional/index.js
Critical dependency: the request of a dependency is an expression
 
../server/node_modules/require_optional/index.js
Critical dependency: the request of a dependency is an expression
Run Code Online (Sandbox Code Playgroud)

runtime-error compiler-errors mongodb node.js next.js

5
推荐指数
1
解决办法
3435
查看次数

Typescript typeRoots 未检测类型定义

我在我的项目中使用 TypeScript。如果我尝试使用 commonJS 导入包

\n
const { v4: uuidv4 } = require(\'uuid\');\n
Run Code Online (Sandbox Code Playgroud)\n

然后我在编译期间不会收到任何错误,但是当我将其转换为 ES6 模块时,例如

\n
import { v4 as uuidv4 } from \'uuid\'; \n
Run Code Online (Sandbox Code Playgroud)\n

我收到如下编译错误:

\n
\n

找不到模块“uuid”的声明文件。\'C:/Users/project/dependencies/nodejs/node_modules/uuid/dist/index.js\' 隐式具有 \'any\' 类型。尝试\'npm i --save-dev @types/uuid\'(如果存在)或添加包含\'声明模块\'uuid\'的新声明(.d.ts)文件;

\n
\n

我已经安装了@types/uuid。

\n

我确实遇到了需要类型定义(@types/*)的包的问题

\n

如果项目结构类似于下面的示例:

\n
const { v4: uuidv4 } = require(\'uuid\');\n
Run Code Online (Sandbox Code Playgroud)\n

要重新生成此问题,请运行下面提到的命令:

\n
import { v4 as uuidv4 } from \'uuid\'; \n
Run Code Online (Sandbox Code Playgroud)\n

将以下 json 添加到 tsconfig.json 文件:

\n
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 dependencies\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 nodejs\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82\xc2\xa0 \xc2\xa0    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node_modules\n\xe2\x94\x82\xc2\xa0 …
Run Code Online (Sandbox Code Playgroud)

node.js node-modules typescript tsconfig microservices

5
推荐指数
2
解决办法
6045
查看次数