Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODULE_NOT_FOUND error after fresh socket-cli install #44

Closed
MichaelvanLaar opened this issue May 7, 2023 · 4 comments
Closed

MODULE_NOT_FOUND error after fresh socket-cli install #44

MichaelvanLaar opened this issue May 7, 2023 · 4 comments

Comments

@MichaelvanLaar
Copy link

After installing socket-cli globally on a machine running Xubuntu, I get the following error:

node:internal/modules/cjs/loader:1042
  throw err;
  ^ng

Error: Cannot find module '/usr/share/nodejs/npm/node_modules/npmlog/lib/log.js'
Require stack:
- /usr/local/lib/node_modules/@socketsecurity/cli/lib/shadow/npm-injection.cjs
- internal/preload
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@socketsecurity/cli/lib/shadow/npm-injection.cjs:128:16)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/@socketsecurity/cli/lib/shadow/npm-injection.cjs',
    'internal/preload'
  ]
}

I’m not a linux expert yet. I couldn’t figure out how to install npmlog into the /usr/share directory.

@bmeck
Copy link
Collaborator

bmeck commented May 8, 2023

What version of node and npm are you running?

$ node --version
$ npm --version

@MichaelvanLaar
Copy link
Author

  • node: 18.13.0
  • npm: 9.2.0

@MichaelvanLaar
Copy link
Author

Managed to solve this by installing an additional node and npm via nvm. Now everything runs, served from directories of my normal user.

@dustin-ruetz
Copy link

dustin-ruetz commented Jun 18, 2024

I wanted to try out the Socket CLI, but after following the safe-npm FAQ I'm receiving the same error listed in OP's initial comment. I tried Node.js v18 as well, but I still receive the same error.

@bmeck Is it expected that the Socket CLI doesn't work with Node.js version managers? OP mentioned using nvm on Xubuntu; I'm currently using fnm on macOS, but the error is exactly the same.

Here's my terminal output, with all commands being run from the ~/ user directory:

$ sw_vers
ProductName:    macOS
ProductVersion: 14.5
BuildVersion:   23F79

$ fnm --version && which fnm
fnm 1.37.1
/opt/homebrew/bin/fnm

$ node -v && which node
v20.14.0
/Users/dustin/.local/state/fnm_multishells/73652_1718675711857/bin/node

$ npm -v && which npm
10.7.0
/Users/dustin/.local/state/fnm_multishells/73652_1718675711857/bin/npm

$ npm install --global @socketsecurity/cli
added 161 packages in 4s
64 packages are looking for funding
  run `npm fund` for details

$ socket --version
0.9.3

$ socket npm install --save-dev typescript
node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module '/Users/dustin/Library/Application Support/fnm/node-versions/v20.14.0/installation/lib/node_modules/npm/node_modules/npmlog/lib/log.js'
Require stack:
- /Users/dustin/Library/Application Support/fnm/node-versions/v20.14.0/installation/lib/node_modules/@socketsecurity/cli/lib/shadow/npm-injection.cjs
- internal/preload
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/dustin/Library/Application Support/fnm/node-versions/v20.14.0/installation/lib/node_modules/@socketsecurity/cli/lib/shadow/npm-injection.cjs:271:16)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at internalRequire (node:internal/modules/cjs/loader:176:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/dustin/Library/Application Support/fnm/node-versions/v20.14.0/installation/lib/node_modules/@socketsecurity/cli/lib/shadow/npm-injection.cjs',
    'internal/preload'
  ]
}

Node.js v20.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants