Error: Cannot find module 'graphlib

Error: Cannot find module ‘graphlib’
Require stack:

  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/node_modules/@snyk/dep-graph/dist/core/create-from-json.js
  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/node_modules/@snyk/dep-graph/dist/index.js
  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/snyk-test/run-test.js
  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/snyk-test/index.js
  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/index.js
  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/analytics.js
  • /home/frappe/frappe-bench/apps/frappe/node_modules/snyk/dist/cli/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object. (/home/frappe/frappe-bench/apps/frappe/node_modules/snyk/node_modules/@snyk/dep-graph/src/core/create-from-json.ts:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    error Command failed with exit code 1.
    info Visit yarn run | Yarn for documentation about this command.
    error Command failed with exit code 1.
    info Visit yarn install | Yarn for documentation about this command.

Tried: npm install graphlib ?

Tried but no luck

Try: bench update --requirements and bench restart

umm… I seem to be getting this error only when running bench update --requirements… and rerunning did not solve my problem…

here is what solved my issue:
I deleted all the node_modules directories using find -type d -name node_modules -prune -exec rm -rf {} \;

and then reran bench update --requirements / bench setup requirements.

2 Likes

This was required too.

This happened to me on develop branch only

Didn’t understand… Can you explain?

nom install graphlib
bench setup requirements

Both were required to be run

1 Like

I got same issue, already install graphlib, but still getting error

Installing node dependencies for frappe
$ yarn install
yarn install v1.22.10
[1/4] Resolving packages…
success Already up-to-date.
$ yarn run snyk-protect
yarn run v1.22.10
$ snyk protect
Error: Cannot find module ‘@snyk/graphlib’
Require stack:

  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk-gradle-plugin/node_modules/@snyk/java-call-graph-builder/dist/call-graph.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk-gradle-plugin/node_modules/@snyk/java-call-graph-builder/dist/java-wrapper.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk-gradle-plugin/node_modules/@snyk/java-call-graph-builder/dist/index.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk-gradle-plugin/dist/index.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/plugins/index.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/plugins/get-single-plugin-result.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/plugins/get-multi-plugin-result.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/plugins/get-deps-from-plugin.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/snyk-test/run-test.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/snyk-test/index.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/index.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/lib/analytics.js
  • /opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk/dist/cli/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/opt/services/frapper/frappe-bench/apps/frappe/node_modules/snyk-gradle-plugin/node_modules/@snyk/java-call-graph-builder/lib/call-graph.ts:1:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    error Command failed with exit code 1.
    info Visit yarn run | Yarn for documentation about this command.
    error Command failed with exit code 1.
    info Visit yarn install | Yarn for documentation about this command.

Installing node dependencies for erpnext
$ yarn install
yarn install v1.22.10
[1/4] Resolving packages…
success Already up-to-date.

Run the below command

npm i @snyk/graphlib

after then maybe you get the below error

Error: Cannot find module ‘xml-js’
Then run the below command

npm i xml-js

1 Like

Thanks @nayanivijay
I have managed to get it’s fixed, same as your suggestion.

this solution worked for me. thanks.

This worked for me too. THanks!