tfjs: Installing @tensorflow/tfjs-node error on windows

Hi! I’m new with node-red and I wanted to install tensor flow, using this in cmd: C:\Users\mahya\.node-red>npm install @tensorflow/tfjs-node But I keep getting some errors . Can you please help? My system information is a Windows 10 Home, 22H2 version. python version: 3.10.6

this is what I get `C:\Users\mahya.node-red>npm install @tensorflow/tfjs-node npm ERR! code 1 npm ERR! path C:\Users\mahya.node-red\node_modules@tensorflow\tfjs-node npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/install.js npm ERR! CPU-windows-4.10.0.zip npm ERR! https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.9.1.zip npm ERR! * Downloading libtensorflow npm ERR! npm ERR! C:\Users\mahya.node-red\node_modules\adm-zip\zipFile.js:101 npm ERR! if (!~endOffset) throw new Error(Utils.Errors.INVALID_FORMAT); npm ERR! ^ npm ERR! npm ERR! Error: Invalid or unsupported zip format. No END header found npm ERR! at readMainHeader (C:\Users\mahya.node-red\node_modules\adm-zip\zipFile.js:101:32) npm ERR! at new module.exports (C:\Users\mahya.node-red\node_modules\adm-zip\zipFile.js:19:9) npm ERR! at new module.exports (C:\Users\mahya.node-red\node_modules\adm-zip\adm-zip.js:62:18) npm ERR! at WriteStream.<anonymous> (C:\Users\mahya.node-red\node_modules@tensorflow\tfjs-node\scripts\resources.js:72:29) npm ERR! at WriteStream.emit (node:events:514:28) npm ERR! at emitCloseNT (node:internal/streams/destroy:132:10) npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:81:21) npm ERR! npm ERR! Node.js v18.17.1

npm ERR! A complete log of this run can be found in: C:\Users\mahya\AppData\Local\npm-cache_logs\2023-08-28T13_33_29_211Z-debug-0.log`

I’ve also attached the log [file.] 2023-08-28T13_33_29_211Z-debug-0.log

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 22 (8 by maintainers)

Most upvoted comments

Downgrading to node-js 18.13.0 solved the problem - latest 18.18.0 was the one with the build errors.

let model; (async () => { model = await tf.loadLayersModel(‘https://kaggle.com/models/google/universal-sentence-encoder/frameworks/TensorFlow1/variations/lite/versions/1’); console.log(‘Model loaded’); })();

I am trying to implement real-time chat communication, but here I am getting errors, I am using

const express = require(‘express’); const http = require(‘http’); const socketIo = require(‘socket.io’); const tf = require(‘@tensorflow/tfjs-node’);

these packages and nodemon to automate any changes, with these version: “@tensorflow-models/universal-sentence-encoder”: “^1.3.3”, “@tensorflow/tfjs”: “^4.17.0”, “@tensorflow/tfjs-node”: “3.10.0”, “express”: “^4.18.3”, “express-ws”: “^5.0.2”, “nodemon”: “^3.1.0”, “socket.io”: “^4.7.4”

throw new Error(message);
^ Error: Failed to parse model JSON of response from https://kaggle.com/models/google/universal-sentence-encoder/frameworks/TensorFlow1/variations/lite/versions/1. Please make sure the server is serving valid JSON for this request. at HTTPRequest.<anonymous> (

@mahyasch

Please use below steps and before that you should follow this official documentation on Windows for node-gyp - Node.js native addon build tool.

I hope it will help you to resolve your issue, if you need any further help let us know. Thank you!

  1. To create one empty folder use, mkdir Folder_Name then go to that folder by using cd Folder_Name
  2. To create empty node.js project use, npm init -y
  3. npm install -g node-gyp
  4. npm install --save-exact @tensorflow/tfjs-node@3.1.0