Free Support Forum - aspose.com

Node.js API: Unable to run example script

Hello, I’m unable to get the node.js API to work when running the “Node.js Example” in the documentation.

After installing aspose.diagram
npm i aspose.diagram

I get the following error message when running the node script.

 node:internal/modules/cjs/loader:922
  throw err;
  ^

Error: Cannot find module '../build/jvm_dll_path.json'
Require stack:
- C:\localDev\VisioFun\node_modules\java\lib\nodeJavaBridge.js
- C:\localDev\VisioFun\node_modules\java\index.js
- C:\localDev\VisioFun\node_modules\aspose.diagram\lib\aspose.diagram.js
- C:\localDev\VisioFun\node_modules\aspose.diagram\index.js
- C:\localDev\VisioFun\index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (C:\localDev\VisioFun\node_modules\java\lib\nodeJavaBridge.js:3:21)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\localDev\\VisioFun\\node_modules\\java\\lib\\nodeJavaBridge.js',
    'C:\\localDev\\VisioFun\\node_modules\\java\\index.js',
    'C:\\localDev\\VisioFun\\node_modules\\aspose.diagram\\lib\\aspose.diagram.js',
    'C:\\localDev\\VisioFun\\node_modules\\aspose.diagram\\index.js',
    'C:\\localDev\\VisioFun\\index.js'
  ]
}

The .json file that is being “required” in the code below does not exist, and I’m unsure as to why that is.
node_modules > java > lib > nodeJavaBridge.js:3:21
process.env.PATH += require('../build/jvm_dll_path.json');

I’m running node v15.3.0, and npm 7.0.15. I also tried and failed with node v14.13.1. I tried multiple installs, and I tried clearing the npm cache. Any idea what might be going on?

Ok, I finally got it working. Here is what I did. I installed:
Node v12.14.1
Java SE JDK 8 (jdk1.8.0_271)

After that, npm install aspose.diagram compiles properly, and my test code works.

I wonder what the latest versions of node and Java JDK are supported?

@augster

It is good to know that your issue has been resolved.

The API has been successfully tested with the Node.js 12.0.x and JDK 1.7/1.8. However, we will further comment on it after gathering more information.