Home > database >  WSL : mocha from sudo apt install mocha crashes with fresh install
WSL : mocha from sudo apt install mocha crashes with fresh install

Time:03-14

As you can see below, I started with state of which mocha returning nothing (not installed), then installed it with sudo apt install mocha, and simply ran mocha hoping to receive some sort of "use /help option for more info".

However, instead, I receive this

Error: Cannot find module 'glob'

Why is this?

REDACTED:/mnt/d/SourceTree$ which mocha

REDACTED:/mnt/d/SourceTree$ sudo apt install mocha
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gyp libauthen-sasl-perl libdata-dump-perl libencode-locale-perl libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl   
  libfile-mimeinfo-perl libfont-afm-perl libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl
  libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl
  libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libjs-is-typedarray libjs-psl
  libjs-typedarray-to-buffer liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libnet-dbus-perl libnet-http-perl      
  libnet-smtp-ssl-perl libnet-ssleay-perl libnode-dev libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib libtie-ixhash-perl     
  libtimedate-perl libtry-tiny-perl liburi-perl libuv1-dev libwww-perl libwww-robotrules-perl libx11-protocol-perl libxml-parser-perl   
  libxml-twig-perl libxml-xpathengine-perl perl-openssl-defaults python-pkg-resources python2 python2-minimal python2.7
  python2.7-minimal python3-cliapp python3-markdown python3-packaging python3-pyparsing python3-ttystatus xdg-utils
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  chai
The following NEW packages will be installed:
  mocha
0 upgraded, 1 newly installed, 0 to remove and 123 not upgraded.
Need to get 0 B/113 kB of archives.
After this operation, 675 kB of additional disk space will be used.
Selecting previously unselected package mocha.
(Reading database ... 72405 files and directories currently installed.)
Preparing to unpack .../mocha_7.0.1 ds1-2_all.deb ...
Unpacking mocha (7.0.1 ds1-2) ...
Setting up mocha (7.0.1 ds1-2) ...
Processing triggers for man-db (2.9.1-1) ...

REDACTED:/mnt/d/SourceTree$ mocha
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'glob'
Require stack:
- /usr/share/nodejs/mocha/lib/utils.js
- /usr/share/nodejs/mocha/bin/mocha
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/share/nodejs/mocha/lib/utils.js:15:12)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/nodejs/mocha/lib/utils.js',
    '/usr/share/nodejs/mocha/bin/mocha'
  ]
}

CodePudding user response:

try this :

npm install --save module_name ( in ur case is glob)

(npm install --save glob)

more info There's already an issue reporting this error message:

CodePudding user response:

I noticed that apt install of mocha was installing v7.0.1. However, the latest mocha was v9 .

What I ended up doing was installing the npm version of the mocha (after sudo apt remove mocha) and ran mocha with npx mocha.

With later versions of mocha, this error did not occur.

  • Related