Skip to content

Commit

Permalink
Fix Node JS Samples (microsoft#23581)
Browse files Browse the repository at this point in the history
### Description
The Node JS Samples included in the repository have outdated package
references that are broken, which are fixed in this PR.

### Motivation and Context
The samples included in this repository should just work, but sadly do
not. The reason is that they are using very outdated references for the
npm modules. This fix updates the dependencies to the current
onnxruntime-node, which fixes the samples. Also adds a small update to
the .gitignore to exclude the node_modules directories in the samples
directory, which keeps the local repo changelist cleaner.
  • Loading branch information
joncamp authored and jatinwadhwa921 committed Feb 5, 2025
1 parent 5322a04 commit 85d8942
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion samples/nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
!**/*.onnx
package-lock.json
package-lock.json
node_modules
2 changes: 1 addition & 1 deletion samples/nodejs/01_basic-usage/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const ort = require('onnxruntime');
const ort = require('onnxruntime-node');

// use an async context to call onnxruntime functions.
async function main() {
Expand Down
2 changes: 1 addition & 1 deletion samples/nodejs/01_basic-usage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"onnxruntime": "0.0.1-dev.20200429.2"
"onnxruntime-node": "^1.20.1"
}
}
2 changes: 1 addition & 1 deletion samples/nodejs/02_create-tensor/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const Tensor = require('onnxruntime').Tensor;
const Tensor = require('onnxruntime-node').Tensor;

//
// create a [2x3x4] float tensor
Expand Down
2 changes: 1 addition & 1 deletion samples/nodejs/02_create-tensor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"onnxruntime": "0.0.1-dev.20200429.2"
"onnxruntime-node": "^1.20.1"
}
}
2 changes: 1 addition & 1 deletion samples/nodejs/04_create-inference-session/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const fs = require('fs');
const util = require('util');
const InferenceSession = require('onnxruntime').InferenceSession;
const InferenceSession = require('onnxruntime-node').InferenceSession;

// use an async context to call onnxruntime functions.
async function main() {
Expand Down
2 changes: 1 addition & 1 deletion samples/nodejs/04_create-inference-session/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"onnxruntime": "0.0.1-dev.20200429.2"
"onnxruntime-node": "^1.20.1"
}
}

0 comments on commit 85d8942

Please sign in to comment.