juba / pyobsplot

Observable Plot in Jupyter notebooks and Quarto documents
https://juba.github.io/pyobsplot/
MIT License
203 stars 7 forks source link

error cb.apply is not a function #30

Closed joshy closed 6 months ago

joshy commented 6 months ago

Hi

I am trying to use the jsdom renderer but I get the following error (latest pyobsplot==0.4.2):

ValueError: Server not started: npm ERR! cb.apply is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     [/home/jarvis/.npm/_logs/2024-05-03T08_53_13_050Z-debug.log](https://jupyter.imaging.ms.uhbs.ch/home/jarvis/.npm/_logs/2024-05-03T08_53_13_050Z-debug.log)
Install for [ 'pyobsplot@0.4.2' ] failed with code 1
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/home/jarvis/.nvm/versions/node/v18.17.1/bin/node',
1 verbose cli   '/home/jarvis/.nvm/versions/node/v18.17.1/lib/node_modules/npx/node_modules/npm/bin/npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'pyobsplot@0.4.2',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   '/home/jarvis/.npm/_npx/3055885',
1 verbose cli   '--loglevel',
1 verbose cli   'error',
1 verbose cli   '--json'
1 verbose cli ]
2 info using npm@5.1.0
3 info using node@v18.17.1
4 verbose npm-session 70f0ac5533eebc63
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/pyobsplot 884ms (from cache)
8 http fetch GET 200 https://registry.npmjs.org/pyobsplot/-/pyobsplot-0.4.2.tgz 7ms (from cache)
9 silly pacote version manifest for pyobsplot@0.4.2 fetched in 930ms
10 verbose stack TypeError: cb.apply is not a function
10 verbose stack     at /home/jarvis/.nvm/versions/node/v18.17.1/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
10 verbose stack     at FSReqCallback.oncomplete (node:fs:211:5)
11 verbose cwd /var/www/jarvis/Auswertung/ge-migration
12 verbose Linux 5.10.0-25-amd64
13 verbose argv "/home/jarvis/.nvm/versions/node/v18.17.1/bin/node" "/home/jarvis/.nvm/versions/node/v18.17.1/lib/node_modules/npx/node_modules/npm/bin/npm-cli.js" "install" "pyobsplot@0.4.2" "--
global" "--prefix" "/home/jarvis/.npm/_npx/3055885" "--loglevel" "error" "--json"
14 verbose node v18.17.1
15 verbose npm  v5.1.0
16 error cb.apply is not a function
17 verbose exit [ 1, true ]

Thanks for any help!

juba commented 6 months ago

Hi,

It seems that the error you get is quite similar to this one ?

https://stackoverflow.com/a/71733685/249691

joshy commented 6 months ago

Hi @juba , thanks for the fast response. I had also installed npx additionally to pyobsplot, maybe that was the reason. Now I get another error, but maybe it is due to my setup. I have install jupyter on a server and the notebook is created from there.

ValueError: Server not started: npm ERR! code ENOENT
npm ERR! syscall spawn sh
npm ERR! path [/var/www/jarvis/Auswertung/ge-migration](https://jupyter.imaging.ms.uhbs.ch/lab/tree/Auswertung/ge-migration/Auswertung/ge-migration)
npm ERR! errno -2
npm ERR! enoent spawn sh ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in: [/home/jarvis/.npm/_logs/2024-05-03T11_07_47_112Z-debug-0.log](https://jupyter.imaging.ms.uhbs.ch/home/jarvis/.npm/_logs/2024-05-03T11_07_47_112Z-debug-0.log)
34 http fetch GET 200 https://registry.npmjs.org/pyobsplot 702ms (cache revalidated)
35 timing arborist:ctor Completed in 1ms
36 timing command:exec Completed in 954ms
37 verbose stack Error: spawn sh ENOENT
37 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:286:19)
37 verbose stack     at onErrorNT (node:internal/child_process:484:16)
37 verbose stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
38 verbose cwd /var/www/jarvis/Auswertung/ge-migration
39 verbose Linux 5.10.0-25-amd64
40 verbose node v20.12.2
41 verbose npm  v10.5.0
42 error code ENOENT
43 error syscall spawn sh
44 error path /var/www/jarvis/Auswertung/ge-migration
45 error errno -2
46 error enoent spawn sh ENOENT
47 error enoent This is related to npm not being able to find a file.
47 error enoent
48 verbose exit -2
49 timing npm Completed in 1106ms
50 verbose code -2
51 error A complete log of this run can be found in: /home/jarvis/.npm/_logs/2024-05-03T11_07_47_112Z-debug-0.log

What version of nodejs and npm are you using? Thanks a lot for your time!

juba commented 6 months ago

If your jupyter installation is on a remote server, is the pyobsplot npm package installed there ?

joshy commented 6 months ago

Ok it was my fault. I had node installed via nvm. However pythons shutil.which("npx") was returning None. For that to fix I added the following to my systemd service file:

Environment="PATH=/home/jarvis/.nvm/versions/node/v20.12.2/bin:$PATH"

The problem is that with systemd the $PATH is not expanded. So probably node executable was not found. I fixed it by changing $PATH to all the paths and now jsdom renderer is working. Thanks for your time and help.

juba commented 6 months ago

Glad to know it is fixed !