cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.48k stars 338 forks source link

npm install -g failed #822

Open Paul75 opened 1 year ago

Paul75 commented 1 year ago

Describe the bug When I install a programme with npm like : npm install -g <APP>

It failed. I've got an error forbidden :

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /nix/store/bkb1nlibmvz2iys8b6lmb386yr021nlv-nodejs-16.20.2/lib/node_modules/generator-ngx-rocket
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/nix/store/bkb1nlibmvz2iys8b6lmb386yr021nlv-nodejs-16.20.2/lib/node_modules/generator-ngx-rocket'
npm ERR!  [Error: EACCES: permission denied, mkdir '/nix/store/bkb1nlibmvz2iys8b6lmb386yr021nlv-nodejs-16.20.2/lib/node_modules/generator-ngx-rocket'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/nix/store/bkb1nlibmvz2iys8b6lmb386yr021nlv-nodejs-16.20.2/lib/node_modules/generator-ngx-rocket'
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/pkbp512/.npm/_logs/2023-09-19T09_03_45_878Z-debug-0.log

To reproduce

launch a terminal go to project and do : npm install -g generator-ngx-rocket

Version

devenv: 0.6.3

domenkozar commented 1 year ago

Running npm config set prefix / should fix it.

mahmoudajawad commented 3 months ago

What can be done in this regard to automate this step as part of devenv shell first run?

domenkozar commented 3 months ago

@mahmoudajawad why do you need to globally install something?

mahmoudajawad commented 3 months ago

@domenkozar, many javascript frameworks have CLI tooling that is provided separately from the actual framework elements. If installing the tooling is not possible with devenv, then the environment user would still be required to install npm (or any package manager), then install the CLI tools in order to have complete experience.

Does devenv suggest different workflow?

domenkozar commented 3 months ago

It's to install the tooling locally and export PATH to make it available within the shell.

mahmoudajawad commented 3 months ago

@domenkozar I see. This means different folder structure in some cases (some CLIs conflict with project files). But, overall it makes sense.