Trouble Installing JSXGraph with npm package

47 views
Skip to first unread message

Daniel Choi

unread,
Jul 15, 2021, 10:28:59 AM7/15/21
to JSXGraph
Hi,

I'm trying to install jsxgraph from npm with the following command

"npm install jsxgraph"

However, I'm still getting the following error

node_modules/jsxgraph/distrib/index.d.ts' is not a module.  TS2306

    2 |
    3 |
  > 4 | import JXG from 'jsxgraph';
      |                 ^
    5 | import  {
    6 |   globalBoardAttributes,
    7 |   LINE,

This is the following installation message after running npm install jsxgraph


$ npm install jsxgraph

> can...@2.8.0 install C:\Users\dchoi\Desktop\Github\econgraphs\node_modules\canvas
> node-pre-gyp install --fallback-to-build

[canvas] Success: "C:\Users\dchoi\Desktop\Github\econgraphs\node_modules\canvas\build\Release\canvas.node" is installed via remote
npm WARN @babel/plugin-bugfix-v8-spread-par...@7.14.5 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsev...@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsev...@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsev...@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsev...@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsev...@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsev...@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ jsxg...@1.2.3
added 32 packages from 22 contributors and audited 1971 packages in 21.375s

147 packages are looking for funding
  run `npm fund` for details

found 5 vulnerabilities (3 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details



And this is the my node_modules folder, and it looks like index.d.ts is successfully installed.
Capture.PNG


I hope that this is enough information to solve this installation issue. Let me know if more information is needed.

Thank You,

Dan

Alfred Wassermann

unread,
Jul 19, 2021, 4:33:33 AM7/19/21
to JSXGraph
Dear Dan,
the TypeScript definition file "index.d.ts" for JSXGraph has been introduced only recently. It is an extremely valuable contribution from an external developer.
So, here in the JSXGraph team, we have to apologize that we are still very new to TypeScript.
Meanwhile, I tested the index.d.js in a mini project. There are a few errors which I could correct or comment out for the moment. You can download the latest version from the github repository.
However, the main problem is that JSXGraph must be included with "require". For me, the following code seems to work:

------- test.ts --------
const JXG = require("jsxgraph");
let board = JXG.JSXGraph.initBoard('box');
---------------

------- tsconfig.json --------
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5"
},
"include": ["./src/**/*"]
}
---------------

Additionally, I had to install
"npm i --save-dev @types/node"

Best wishes,
Alfred




Reply all
Reply to author
Forward
0 new messages