分叉库的 npm install 无法完全安装

问题描述 投票:0回答:1

我正在开发一个使用 Nest js 制作的私有 Node js 项目。我正在使用 node-coap 库,我已将其分叉到我公司的 github 配置文件中。我使用 npm install /node-coap 将其安装到项目中,但它未完全安装到我的 node_modules 文件夹中。结果我编译不成功,出现这个错误:

2023-07-11 14:32:54 src/coap/coap.controller.ts:2:24 - error TS2307: Cannot find module 'coap' or its corresponding type declarations.

2023-07-11 14:32:54

2023-07-11 14:32:54 2 import { Server } from 'coap';

2023-07-11 14:32:54                          ~~~~~~

2023-07-11 14:32:54 

2023-07-11 14:32:54 src/coap/coap.module.ts:4:23 - error TS2307: Cannot find module 'coap' or its corresponding type declarations.

2023-07-11 14:32:54 

2023-07-11 14:32:54 4 import * as coap from 'coap';

2023-07-11 14:32:54                         ~~~~~~

这是我在节点模块中看到的(它已将自己命名为coap):Installed coap module inside my node_modules folder, shows only some files from the many on github.

我不知道如何正确安装它,这已经成为我开发任务中的一个巨大障碍。请帮忙!

我在这个网站这个网站尝试了这些解决方案,但没有成功。最后,我尝试添加一个

"prebuild":"npm run build"
的脚本,当我安装分叉的node-coap时,它给了我这个错误,显然是因为它在node_modules中找不到它。

npm ERR! path /home/User/Work/project/project-module/node_modules/coap
npm ERR! command failed
npm ERR! command sh -c npm run build
npm ERR! > [email protected] build
npm ERR! > tsc -b
npm ERR! 
npm ERR! error TS5083: Cannot read file '/home/User/Work/project/project-module/node_modules/coap/tsconfig.json'.

npm ERR! A complete log of this run can be found in: 2023-07-11T10_40_22_375Z-debug-0.log```


javascript node.js npm node-modules
1个回答
0
投票

现在我直接从 npm 安装了相同的包,它会自行将其添加到 package.json 中,并完全安装所有文件。

© www.soinside.com 2019 - 2024. All rights reserved.