Node.exe 即使安装后也找不到模块 jspdf

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

我正在尝试使用 Node.exe(Windows 上的 v14.18.1)运行独立的 TypeScript 脚本。该脚本首先需要 jspdf 和 jspdf-autotable:

const { jsPDF } = require("jspdf"); 
require("jspdf-autotable"); 

所以我安装这些模块:

npm install --global --force [email protected] [email protected]

但是,我尝试使用

运行脚本
node MyScript.ts

我收到此错误:

Error: Cannot find module 'jspdf'

我是 Node 开发世界的新手,希望得到任何帮助。谢谢。

node.js typescript jspdf jspdf-autotable
1个回答
0
投票

您必须安装 @types/jspdf 和 @types/jspdf-autotable 作为开发依赖项。

npm install @types/jspdf @types/jspdf-autotable --save-dev

来自

flo-ragossnig答案

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