RedisAI / redisai-js

A high-performance JavaScript client for RedisAI
https://redisai.io
BSD 3-Clause "New" or "Revised" License
13 stars 4 forks source link

Syntax Error upon import #24

Open guyroyse opened 3 years ago

guyroyse commented 3 years ago

I'm getting a syntax error doing the simplest of things:

$ npm install --save redisai-js

I copy and paste the Vanilla JS tensor example from the README.md into a file named redisai-js.js. And then I run it:

$ node redisai-js.js

And it gives me this error:

/Users/guyroyse/code/redis-modules-assessment/node_modules/redisai-js/lib/tensor.js:49
    });
    ^

SyntaxError: Unexpected token '}'
    at wrapSafe (internal/modules/cjs/loader.js:931:16)
    at Module._compile (internal/modules/cjs/loader.js:979:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/guyroyse/code/redis-modules-assessment/node_modules/redisai-js/lib/index.js:10:16)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)

I pulled the repo down myself, built everything, and npm installed the folder on my machine and it worked. Seems like something wrong with our npm depoly? Maybe?

filipecosta90 commented 3 years ago

Hi there @guyroyse , I've created a empty project and used the sample tensor from the readme and it seems to work for me. Do we differ in any of the following versions?:

filipe@filipe-ThinkPad-T490:/tmp/test$ node --version
v14.13.0
filipe@filipe-ThinkPad-T490:/tmp/test$ npm list 
test@1.0.0 /tmp/test
└─┬ redisai-js@1.0.0
  ├─┬ @types/redis@2.8.28
  │ └── @types/node@14.14.25
  └─┬ redis@3.0.2
    ├── denque@1.5.0
    ├── redis-commands@1.6.0
    ├── redis-errors@1.2.0
    └─┬ redis-parser@3.0.0
      └── redis-errors@1.2.0 deduped

filipe@filipe-ThinkPad-T490:/tmp/test$ node tensor.js 
AI.TENSORSET result: OK
AI.TENSORGET reply: datatype FLOAT shape [1,2] , data [3,5]
filipecosta90 commented 3 years ago

PS: nonetheless, to be sure, I can add the Readme examples to the CI as part of clean independent examples ( each of them ). wdyt?

guyroyse commented 3 years ago

That certainly couldn't hurt. I checked my version and stuff to compare and upgraded my Node from 12 to 14. But, still getting the error. This is really weird:

14:55:01 guyroyse@macaquebook.local ~/code/redisai-syntax-error 
🐵 node server.js 
/Users/guyroyse/code/redisai-syntax-error/node_modules/redisai-js/lib/tensor.js:49
    });
    ^

SyntaxError: Unexpected token '}'
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/guyroyse/code/redisai-syntax-error/node_modules/redisai-js/lib/index.js:10:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
14:55:13 guyroyse@macaquebook.local ~/code/redisai-syntax-error 
🐵 node --version
v14.15.4
14:55:18 guyroyse@macaquebook.local ~/code/redisai-syntax-error 
🐵 npm list
redisai-syntax-error@1.0.0 /Users/guyroyse/code/redisai-syntax-error
└─┬ redisai-js@1.0.0
  ├─┬ @types/redis@2.8.28
  │ └── @types/node@14.14.25
  └─┬ redis@3.0.2
    ├── denque@1.5.0
    ├── redis-commands@1.6.0
    ├── redis-errors@1.2.0
    └─┬ redis-parser@3.0.0
      └── redis-errors@1.2.0 deduped

How did you install Node? I'm using nvm.

Note: Yes. I have a monkey in my command prompt. ;)

simonprickett commented 3 years ago

I am able to reproduce @guyroyse findings using Mac OS Catalina 10.15.7 and Node 14.16.0, here's my output:

$ node server.js
/Users/simonprickett/source/github/redisai-syntax-error/node_modules/redisai-js/lib/tensor.js:49
    });
    ^

SyntaxError: Unexpected token '}'
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/simonprickett/source/github/redisai-syntax-error/node_modules/redisai-js/lib/index.js:10:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
redisai-syntax-error $ vi /Users/simonprickett/source/github/redisai-syntax-error/node_modules/redisai-js/lib/tensor.js
guyroyse commented 3 years ago

I am running macOS Catalina 10.15.7 as well. I also experienced this same problem on an earlier Mac.