ioBroker / create-adapter

Command line utility to create customized ioBroker adapters
MIT License
50 stars 23 forks source link

Installation of global packages (dev-server) fails on Linux systems (and probably other systems as well) #927

Open Garfonso opened 2 years ago

Garfonso commented 2 years ago

On all the Linux systems I did work with, the 'global' node_modules path is global and read only for ordinary users. This is a difference to the windows world, where the 'global' node_modules path today is in the user's home directory (and therefore depends on the user, i.e. 'global' is a bit misleading).

But for that reason during a run of create adapter, the installation of dev-server fails, because it can not be installed globally without the use of sudo (or any other means to get administration rights in a system). If dev-server is already installed, the creation will still work as supposed to (but users might be scared by error messages). If it is not installed beforehand, dev-server setup will probably fail (did not test, what happens then).

So one mitigation could be to explain in README that for Linux systems the user should install dev-server manually. Not sure if other measures are possible / feasible.

Error messages:

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/@iobroker/dev-server
npm ERR! dest /usr/lib/node_modules/@iobroker/.dev-server-pCFaCClW
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/@iobroker/dev-server' -> '/usr/lib/node_modules/@iobroker/.dev-server-pCFaCClW'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/lib/node_modules/@iobroker/dev-server' -> '/usr/lib/node_modules/@iobroker/.dev-server-pCFaCClW'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/lib/node_modules/@iobroker/dev-server',
npm ERR!   dest: '/usr/lib/node_modules/@iobroker/.dev-server-pCFaCClW'
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/achim/.npm/_logs/2022-06-24T09_58_36_982Z-debug-0.log

(the error message is a bit cryptic, but from the debug log it seems that npm first wants to rename the existing dev-server in order to copy in the new one and delete the old one - npm version 8.6.0).

AlCalzone commented 2 years ago

Duplicate of https://github.com/ioBroker/create-adapter/issues/891? And strongly related to https://github.com/ioBroker/create-adapter/issues/864

Garfonso commented 2 years ago

Duplicate of #891? And strongly related to #864

Not a duplicate of #891, because this is not on Linux and dev-server fails for a different reason (ok.. Maybe depends on the fix. If there is somehow a general handling of dev-server install failure, this might fix both. So it is related).

And yes, very related to #864. The "right" solution will solve this issue, too.

AlCalzone commented 2 years ago

Right, I overlooked that the other issue is on Windows