Skip to content

Commit cd8775f

Browse files
authored
Fix Node JS Samples (microsoft#23581)
### 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.
1 parent 6b4f9c4 commit cd8775f

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

samples/nodejs/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
!**/*.onnx
2-
package-lock.json
2+
package-lock.json
3+
node_modules

samples/nodejs/01_basic-usage/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const ort = require('onnxruntime');
2+
const ort = require('onnxruntime-node');
33

44
// use an async context to call onnxruntime functions.
55
async function main() {

samples/nodejs/01_basic-usage/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"dependencies": {
10-
"onnxruntime": "0.0.1-dev.20200429.2"
10+
"onnxruntime-node": "^1.20.1"
1111
}
1212
}

samples/nodejs/02_create-tensor/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const Tensor = require('onnxruntime').Tensor;
2+
const Tensor = require('onnxruntime-node').Tensor;
33

44
//
55
// create a [2x3x4] float tensor

samples/nodejs/02_create-tensor/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"dependencies": {
10-
"onnxruntime": "0.0.1-dev.20200429.2"
10+
"onnxruntime-node": "^1.20.1"
1111
}
1212
}

samples/nodejs/04_create-inference-session/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
const fs = require('fs');
33
const util = require('util');
4-
const InferenceSession = require('onnxruntime').InferenceSession;
4+
const InferenceSession = require('onnxruntime-node').InferenceSession;
55

66
// use an async context to call onnxruntime functions.
77
async function main() {

samples/nodejs/04_create-inference-session/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"dependencies": {
10-
"onnxruntime": "0.0.1-dev.20200429.2"
10+
"onnxruntime-node": "^1.20.1"
1111
}
1212
}

0 commit comments

Comments
 (0)