etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

MODULE_NOT_FOUND

Open TobiasReich opened this issue 3 years ago • 19 comments

Describe the bug Installing any plugin seems to break the installation.

To Reproduce Steps to reproduce the behavior:

  1. Installing clean Etherpad (all runs fine without plugins)
  2. in /opt/etherpad run $npm install --no-save --legacy-peer-deps ep_adminpads2 (or any other)
  3. run etherpad (even manually) $/usr/bin/node --experimental-worker ./node_modules/ep_etherpad-lite/node/server.js

Leads to the error:

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module '/opt/etherpad/node_modules/ep_etherpad-lite/node/server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Expected behavior It should install a pluginand run the pad.

Server (please complete the following information):

  • Etherpad version: 1.8.18
  • OS: Ubuntu 20.04
  • Node.js version 14.20.0
  • npm version 6.14.15
  • Is the server free of plugins: yes (before I try to install one)

NOTE: This seems to happen with any of the plugins. My example with adminpads2 is just one of many. Calling ./bin/installDeps.sh afterwards fixes the issue but causes all plugins to be "removed" afterwards so that is no solution.

TobiasReich avatar Jul 19 '22 13:07 TobiasReich

Had another look at what is happening and saw that the npm install calls area clearing the node_modules folder except for the newly installed package and a .package-lock.json file.

E.g. when calling npm install --no-save --legacy-peer-deps ep_align only the ep_align package and it's dependencies are there (and the rest got deleted).

TobiasReich avatar Jul 20 '22 08:07 TobiasReich

I have the same issue.

simondueckert avatar Jul 23 '22 19:07 simondueckert

Unfortunatelly the same behavior here with Node v18.14.0 and etherpad 1.8.18

/usr/bin/node --experimental-worker ./node_modules/ep_etherpad-lite/node/server.js

node:internal/modules/cjs/loader:1050
  throw err;
  ^

Error: Cannot find module '/usr/local/etherpad/node_modules/ep_etherpad-lite/node/server.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1047:15)
    at Module._load (node:internal/modules/cjs/loader:893:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

p3t3r67x0 avatar Feb 09 '23 20:02 p3t3r67x0

I also have this same issue. Installing a plugin using the following command erased all the node_modules: npm install --no-save --legacy-peer-deps ep_webrtc

michaelcalvinwood avatar Feb 27 '23 01:02 michaelcalvinwood

The issue you're encountering with Etherpad plugins being removed when you install them is likely due to a conflict or issue with the way npm manages dependencies and handles the node_modules directory. It's essential to address this problem to ensure you can install and use plugins successfully.

rishi457 avatar Oct 03 '23 05:10 rishi457

I ran into the same problem. Is there already a solution for this, so that I can install plugins?

I use etherpad on an up-to-date Debian installation with Etherpad 1.9.7 (6814aa9) (cloned from git) node 18.19.0 (installed from Debian)

When I run npm version, I get the version 9.2.0, but the logfile tells me plugins - npm --version: 6.14.18.

sphh avatar Mar 12 '24 18:03 sphh

I ran into the same problem. Is there already a solution for this, so that I can install plugins?

I use etherpad on an up-to-date Debian installation with Etherpad 1.9.7 (6814aa9) (cloned from git) node 18.19.0 (installed from Debian)

When I run npm version, I get the version 9.2.0, but the logfile tells me plugins - npm --version: 6.14.18.

Oh that is a problem that has been with Etherpad forever. It will be fixed in v2 but for now you need to install npm install -g npm@6 or alternatively use the develop branch.

SamTV12345 avatar Mar 12 '24 19:03 SamTV12345

I tried to install a plugin with npm install -g npm@6 --no-save --legacy-peer-deps and get the following error:

npm ERR! code EACCES                                                                                                                         
npm ERR! syscall mkdir                                                                                                                       
npm ERR! path /usr/local/lib/node_modules                                                                                                    
npm ERR! errno -13                                                                                                                           
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'                                                               
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Looks to my, that npm install -g npm@6 tries to install the plugin into the system directory and not the local one. Is there another command line parameter which is needed?

sphh avatar Mar 12 '24 19:03 sphh

I tried to install a plugin with npm install -g npm@6 --no-save --legacy-peer-deps and get the following error:

npm ERR! code EACCES                                                                                                                         
npm ERR! syscall mkdir                                                                                                                       
npm ERR! path /usr/local/lib/node_modules                                                                                                    
npm ERR! errno -13                                                                                                                           
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'                                                               
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Looks to my, that npm install -g npm@6 tries to install the plugin into the system directory and not the local one. Is there another command line parameter which is needed?

You just need to use npm install -g npm@6. The command overrides your version of npm v9.2.0 with npm version 6. This is the last version that works with the old Etherpad release

SamTV12345 avatar Mar 12 '24 19:03 SamTV12345

Thanks. But unfortunately if I just use npm install -g npm@6 <plugin> I get the very same error message …

sphh avatar Mar 12 '24 19:03 sphh

I guess, -g stands for --global. Shouldn't npm install the plugin locally?

sphh avatar Mar 12 '24 19:03 sphh

Thanks. But unfortunately if I just use npm install -g npm@6 <plugin> I get the very same error message …

Yes. Leave out the and just do the mentioned command. You maybe require sudo as it installs npm globally for that.

SamTV12345 avatar Mar 12 '24 20:03 SamTV12345

Ok, I now got them installed globally under sudo. When I (re)start etherpad, those plugins are not picked up:

Mar 12 21:16:12 qqq systemd[1]: Started etherpad.service - Etherpad-lite, the collaborative editor.
Mar 12 21:16:12 qqq node[2318497]: [2024-03-12T21:16:12.722] [INFO] settings - All relative paths will be interpreted relative to the identified Etherpad base dir: /usr/local/share/etherpad/src
Mar 12 21:16:12 qqq node[2318497]: [2024-03-12T21:16:12.759] [INFO] settings - settings loaded from: /usr/local/share/etherpad/src/settings.json
Mar 12 21:16:12 qqq node[2318497]: [2024-03-12T21:16:12.767] [INFO] settings - No credentials file found in /usr/local/share/etherpad/src/credentials.json. Ignoring.
Mar 12 21:16:12 qqq node[2318497]: [2024-03-12T21:16:12.769] [INFO] settings - Using skin "colibris" in dir: /usr/local/share/etherpad/src/src/static/skins/colibris
Mar 12 21:16:12 qqq node[2318497]: [2024-03-12T21:16:12.769] [WARN] settings - DirtyDB is used. This is not recommended for production. File location: /usr/local/share/etherpad/src/var/dirty.db
Mar 12 21:16:12 qqq node[2318497]: [2024-03-12T21:16:12.771] [INFO] settings - Random string used for versioning assets: 19d93044
Mar 12 21:16:14 qqq node[2318497]: [2024-03-12T21:16:14.930] [INFO] server - Starting Etherpad...
Mar 12 21:16:15 qqq node[2318497]: [2024-03-12T21:16:15.030] [INFO] plugins - check installed plugins for migration
Mar 12 21:16:15 qqq node[2318497]: [2024-03-12T21:16:15.033] [INFO] plugins - Loading plugin ep_etherpad-lite...
Mar 12 21:16:15 qqq node[2318497]: [2024-03-12T21:16:15.048] [INFO] plugins - Loaded 1 plugins
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.623] [INFO] APIHandler - Api key file read from: "/usr/local/share/etherpad/src/APIKEY.txt"
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.809] [INFO] server - Installed plugins:
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.845] [INFO] settings - Report bugs at https://github.com/ether/etherpad-lite/issues
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.855] [INFO] settings - Your Etherpad version is 1.9.7 (6814aa9)
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.860] [INFO] settings - SSL -- enabled
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.861] [INFO] settings - SSL -- server key file: /usr/local/share/etherpad/ssl/epl-server.key
Mar 12 21:16:16 qqq node[2318497]: [2024-03-12T21:16:16.866] [INFO] settings - SSL -- Certificate Authority's certificate file: /usr/local/share/etherpad/ssl/epl-server.crt
Mar 12 21:16:22 qqq node[2318497]: [2024-03-12T21:16:22.242] [INFO] plugins - npm --version: 6.14.18
Mar 12 21:16:22 qqq node[2318497]: [2024-03-12T21:16:22.303] [INFO] http - HTTP server listening for connections

sphh avatar Mar 12 '24 20:03 sphh

Now you need to install npm install in the etherpad root directory. You need to make sure that pacakge-lock.json in src says version 1 instead of 3

SamTV12345 avatar Mar 12 '24 20:03 SamTV12345

Thanks for talking me through this. Do you have a tutorial ready for this?

How do I install npm in the etherpad root directory (sorry, I have never worked with nodes and npm before)?

There are many, many version strings in package-lock.json. Which one should I change from 3 to 1?

sphh avatar Mar 12 '24 20:03 sphh

Oh alright no worries. So first you did

  1. npm install -g npm@6 <- This installs the correct npm version
  2. Go to the etherpad directory, into src and remove the package-lock.json file
  3. Remove the node_modules file
  4. Do ./bin/installDeps.sh
  5. Now you should be ready to start etherpad with ./bin/run.sh

SamTV12345 avatar Mar 12 '24 21:03 SamTV12345

Thanks. I followed your step-by-step instructions. I performed 1. as root and 2.-4. as the etherpad user.

The command ./bin/installDeps.sh gives me the following error:

$ bin/installDeps.sh                                                                                                                                                                                                              
Installing dependencies...                                                                                                                                                                                                        
Installing dev dependencies                                                                                                                                                                                                       
npm WARN config optional Use `--omit=optional` to exclude optional dependencies, or                                                                                                                                               
npm WARN config `--include=optional` to include them.                                                                                                                                                                             
npm WARN config                                                                                                                                                                                                                   
npm WARN config     Default value does install optional deps unless otherwise omitted.                                                                                                                                            
npm ERR! code EUSAGE                                                                                                                                                                                                              
npm ERR!                                                                                                                                                                                                                          
npm ERR! The `npm ci` command can only install with an existing package-lock.json or                                                                                                                                              
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or                                                                                                                                              
npm ERR! later to generate a package-lock.json file, then try again.                                                                                                                                                              
npm ERR!                                                                                                                                                                                                                          
npm ERR! Clean install a project
npm ERR! 
npm ERR! Usage:
npm ERR! npm ci
npm ERR! 
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--install-strategy <hoisted|nested|shallow>]
npm ERR! [--legacy-bundling] [--global-style]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--no-install-links]
npm ERR! 
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR! 
npm ERR! Run "npm help ci" for more info

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/local/share/etherpad/.npm/_logs/2024-03-12T21_29_00_378Z-debug-0.log

sphh avatar Mar 12 '24 21:03 sphh

Oops. Sorry. Didn't know that the old script was this silly. Then please go before into the src directory and do npm install.

SamTV12345 avatar Mar 12 '24 21:03 SamTV12345

I am a bit confused. Is that what you mean:

  1. sudo npm install -g npm@6 <- This installs the correct npm version
  2. cd etherpad/src/
  3. rm package-lock.json
  4. rm -R node_modules
  5. npm install
  6. ./bin/installDeps.sh

And then I should be able to install plugins with npm install -g npm@6 --no-save --legacy-peer-deps <ep_plugin>?

sphh avatar Mar 12 '24 21:03 sphh