【问题标题】:Requiring mathjs需要数学
【发布时间】:2021-07-07 13:49:22
【问题描述】:

我尝试将 mathjs 库包含到我的 atan2() 项目中。当我尝试包含我使用 npm install @types/mathjs by var Math = require('mathjs/main/es5/index'); 安装的文件夹时,它会抛出一个错误,它已被移动,我必须包含 mathjs 或 mathjs/lib/cjs/index.js 。然而,这也不起作用。那么如何包含 mathjs 库呢?

文件“mathjs/main/es5/index.js”已被移动 数学@8.0.0。请加载“mathjs”或“mathjs/lib/cjs/index.js”

【问题讨论】:

  • 我不知道你的问题的答案,但vanilla JS has an atan2 function
  • 试试 const Math = require('mathjs');
  • 我试过 const Math = require('mathjs');不起作用,对于 Nodejs v12.13.1 和 Javascript (V8) 7.7.299.13-node.16 它返回一个 ReferenceError: atan2 is not defined

标签: javascript mathjs


【解决方案1】:

你安装的只是你需要 @types/mathjs 依赖的包本身的类型。

npm i mathjs
npm i -D @types/mathjs

然后你可以像这样从'mathjs'导入

import { max, pi, acos } from 'mathjs'

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-29
    • 2012-09-22
    • 2010-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多