JupyterLab plotly extension error: Cannot find module jupyter\lab\staging\node_modules\ejs\postinstall.js

Viewed 1337

I am trying to install JupyterLab renderer support for Plotly using:

jupyter labextension install jupyterlab-plotly@4.10.0

and I get

RuntimeError: npm dependencies failed to install

The log file contains the following:

[LabBuildApp] Building in C:\Users\<user>\anaconda3\share\jupyter\lab
[LabBuildApp] Node v14.11.0

[LabBuildApp] Yarn configuration loaded.
[LabBuildApp] Building jupyterlab assets (build:prod:minimize)
[LabBuildApp] > node C:\Users\<user>\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js install --non-interactive
[LabBuildApp] yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents@2.1.3: The platform "win32" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > @lumino/coreutils@1.5.0" has unmet peer dependency "crypto@1.0.1".
[5/5] Building fresh packages...
error C:\Users\<user>\anaconda3\share\jupyter\lab\staging\node_modules\ejs: Command failed.
Exit code: 1
Command: node ./postinstall.js
Arguments: 
Directory: C:\Users\<user>\anaconda3\share\jupyter\lab\staging\node_modules\ejs
Output:
internal/modules/cjs/loader.js:896
  throw err;
  ^

Error: Cannot find module 'C:\Users\<user>\anaconda3\share\jupyter\lab\staging\node_modules\ejs\postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:893:15)
    at Function.Module._load (internal/modules/cjs/loader.js:743:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

[LabBuildApp] npm dependencies failed to install
[LabBuildApp] Traceback (most recent call last):

[LabBuildApp]   File "C:\Users\<user>\anaconda3\lib\site-packages\jupyterlab\debuglog.py", line 47, in debug_logging
    yield

[LabBuildApp]   File "C:\Users\<user>\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 138, in start
    raise e

[LabBuildApp]   File "C:\Users\<user>\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 134, in start
    build(name=self.name, version=self.version,

[LabBuildApp]   File "C:\Users\<user>\anaconda3\lib\site-packages\jupyterlab\commands.py", line 459, in build
    return handler.build(name=name, version=version, static_url=static_url,

[LabBuildApp]   File "C:\Users\<user>\anaconda3\lib\site-packages\jupyterlab\commands.py", line 652, in build
    raise RuntimeError(msg)

[LabBuildApp] RuntimeError: npm dependencies failed to install

[LabBuildApp] Exiting application: JupyterLab

When I open JupyterLab I am asked to do a

jupyter lab build

After my attempt, I get the same error in the logfile.

I am using Windows10, node.js 14.11.0 (installed using conda), JupyterLab 2.1.5

Note that I have tried:

  • uninstalling conda's node.js and installing node.js directly from node-v12.18.3-x64.msi
  • uninstalling and installing Anaconda

both with no luck.

3 Answers

It may be a problem with firewall.

Try setting a proxy in npm's config, or even turn strict-ssl off:

npm config set strict-ssl false

and

npm config set proxy http://host:port

for http

or

npm config set https-proxy https://host:port

for https

OK so I think see why this is happening, version 2 of ejs had a post install script, but it was removed from version 3. It looks like another package cjs is trying to directly call ejs/postInstall.js for some reason.

It looks like you have some dependancies out of sync. My suggestion would to delete node_modules and package-lock.json and try the install command again.

If that doesn't work look for any other lock files, such as yarn.lock and delete them and node_modules again.

Good luck

From your previous comment, you confirmed that you are not behind any proxy, which is one of the most common reason for these errors. Even I tried installing the jupyter lab and plotly extension, as I also wanted to give it a try, it worked for me without any error.

Issue can be very specific with your environment. And mostly because of corrupt npm package. You can try any of below step, it may do the trick

  1. Move to directory C:\Users\anaconda3\share\jupyter\lab\staging, and delete node_module folder. After deleting folder try running command yarn install from same folder. If no error then you should be good.

  2. If above doesn't work, you can reset yarn cache using command yarn cache clean. And retry step 1.

  3. Still if it doesn't work, try deleting yarn.lock file, then step 2 and 1.

Node: Please backup the files you are going to delete. Also there is no way to tell which step will work for you, its just hit and trial.

Related