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

Cannot find module "config" upon install #3

Closed
yaqubroli opened this issue Aug 22, 2023 · 3 comments
Closed

Cannot find module "config" upon install #3

yaqubroli opened this issue Aug 22, 2023 · 3 comments

Comments

@yaqubroli
Copy link

When I try and install zotra-cli with npm install -g . in the cloned directory, it initially gave this error:

% zotra
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'config'
Require stack:
- /Users/yaqub/Library/Mobile Documents/com~apple~CloudDocs/Development/zotra-cli/bin/index.js
- ...

Note that the require stack contained my personal development directory that I cloned this repo to, not where my node modules are actually stored systemwide (/opt/homebrew/lib/node_modules.) In fact, if I go there, I do see a zotra directory, but it only contains the src folder, and thus only attachments.js. I am assuming this is not intended behaviour, so I added the following to package.json:

  "files": [
    "bin",
    "config",
    "module",
    "src"
  ],

After that, all of the folders were safely in the zotra/ directory in node-modules, but when I ran zotra from the command line, it still got the above error (complete with a stack trace still referencing my development folder). Despite this, the actual zotra command itself seems to be referring now to the bin/index.js in my systemwide node_modules.

% which zotra
/opt/homebrew/bin/zotra
% ls -l /opt/homebrew/bin/zotra
lrwxr-xr-x  1 yaqub  admin  38 22 Aug 14:38 /opt/homebrew/bin/zotra -> ../lib/node_modules/zotra/bin/index.js

I am not sure what's going on here; either this is me screwing up (quite likely) or there is code in index.js that uses some kind of environment variable that isn't activated when npm is installed through homebrew, maybe?

@yaqubroli
Copy link
Author

It appears that it works fine when installed locally and not in system-wide node_modules, so I'm employing that as a temporary solution for now. While I think the config error might be a red herring (I'm assuming it's referring to the config in the repo and not the npm package of the same name,) something about global installation is not resolving on my system.

Notably, I tried with nvm instead of node installed through Homebrew, and it still gave me this error. I'm on macOS Ventura 14.3.1.

This is the message I see (after the some deprecated warnings and stuff) when I install locally: added 387 packages, and audited 389 packages in 11s.

Whereas globally it seems to not even get that there's dependencies and just say added 1 package in 88ms.

@gwbrck
Copy link

gwbrck commented Aug 23, 2023

For me, the global installation also only worked if I installed local first.

@mpedramfar
Copy link
Owner

mpedramfar commented Aug 23, 2023

The config refers to the npm package. If you clone this repo and try to run it without installing it, you'll get the same error.
A similar issue seems to happen in Windows as well. My guess is that it's about some environment variable.

Seems like global installation of nodejs packages is a mess. On both macOS and Windows, it's tricky and on Linux by default it would need root access. I'll change the README to say local install is the recommended method.

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