I have error for install electron on fedora 30 - node.js

Hello i have this error if i try to install electron on my fedora 30
[luisjustin#localhost ~]$ sudo su
[sudo] password for luisjustin:
[root#localhost luisjustin]# npm install -g electron
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js
> electron#5.0.2 postinstall /usr/lib/node_modules/electron
> node install.js
/usr/lib/node_modules/electron/install.js:49
throw err
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#5.0.2 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#5.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-05-30T01_21_04_805Z-debug.log
[root#localhost luisjustin]#
the log in this link: https://pastebin.com/q3dSCQVg

There seems to be an issue with permissions on your machine (/usr/lib directory requires root access). What I suggest you to try is to change the default directory where NPM is installing packages globally. Then you can try to run the installation without root access.
Try this:
On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
To test your new configuration, install a package globally without using sudo:
npm install -g electron
Courtesy:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Related

updating node and npm from npm 6 to 8 and node 14 to 16 or 18 on a react native project , fails on ENOENT

Getting an error after running npm install,
It seems that npm is not pathed right for this file or something is cached?
I'm using homebrew and nvm to switch between versions, but the only version that works is node 14 and npm 6.
Need to install the following packages:
pod#0.9.0
Ok to proceed? (y) y
npm ERR! syscall chmod
npm ERR! path /Users/me/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/me/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2022-08-04T19_23_48_147Z-debug-0.log
npm ERR! code 254
npm ERR! path /Users/me/repos/MyApp/MyMobileApp
npm ERR! command failed
npm ERR! command sh /var/folders/d2/rdhvx2fd24vbsfrtf3lddq9m0000gq/T/postinstall-a0c95179.sh
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2022-08-04T19_23_45_192Z-debug-0.log
```. i get User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES
error: Could not delete `/Users/me/repositories/MyApp/ios/build` because it was not created by the build system.
note: To mark this directory as deletable by the build system, run `xattr -w com.apple.xcode.CreatedByBuildSystem true /Users/me/repositories/MyApp/ios/build` when it is created.
error: Could not delete `/Users/me/repositories/MyApp/ios/build` because it was not created by the build system.
note: To mark this directory as deletable by the build system, run `xattr -w com.apple.xcode.CreatedByBuildSystem true /Users/me/repositories/MyApp/ios/build` when it is created.
** CLEAN FAILED **
Is now something that happens when I run xcodebuild -alltargets clean
This may be due to cache. Try below step and check if it works
Run rm -rf ~/.npm
Run npm cache clean --force
Remove node_modules (run rm -rf node_modules)
Remove package-lock.json (run rm -rf package-lock.json)
It happens when npm install conflict with peer dependencies
--legacy-peer-deps that ignores all peer dependencies when installing.
So the best approch is to use --legacy-peer-deps
npm install --legacy-peer-deps

Error while running (npm install -g #angular/cli) in mac

I'm trying to install angular/cli and when I run
npm install -g #angular/cli
in the terminal I come up with these error messages, furthermore, I tried to use sudo as a prefix but again not a positive result.
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git#github.com/angular/cli.git
npm ERR!
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2018-10-06T04_44_40_632Z- debug.log
npm packages should be installed without sudo in macos
Infact sudo should be never be used unless tinkering with system wide
permissions. Node puts npm packages in a specific folder, usually
/usr/local/lib/node_modules. But the trouble is you need sudo
permissions to write here. This leads to an endless use of
non-requisite sudo permissions. This location is what we need to
change and here are handy terminal commands to achieve the same:
mkdir ~/.npm
npm config set prefix ~/.npm
nano ~/.bashrc
export PATH="$PATH:$HOME/.npm/bin"
source ~/.bashrc
Quoted from here: https://medium.com/#Mandysidana/using-npm-install-without-sudo-2de6f8a9e1a3
Finally, I found the answer
Here is the code just run in terminal:
sudo npm install -g #angular/cli

NPM cannot install module, permission denied with mkdir

I am attempting to globally install the electron module with npm on OS X Sierra. When I run
sudo npm install electron -g
I get
/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js
> electron#1.7.5 postinstall /usr/local/lib/node_modules/electron
> node install.js
/usr/local/lib/node_modules/electron/install.js:48
throw err
^
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/dist'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#1.7.5 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#1.7.5 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ianwise/.npm/_logs/2017-08-10T22_16_42_927Z-debug.log
The problem seems to be a permission denied when npm runs mkdir... But I'm running this with sudo, so why is this a problem?
I think you're running as root. run the following command.
npm config set unsafe-perm true
sudo npm install electron -g
I had exactly the same issue with electron.
Assuming you have checked that the relevant directories are writable with:
$ ls -l
In the end I tried without sudo and it worked...!
$ npm install electron -g
The process completed with a message saying:
npm notice created a lockfile as package-lock.json. You should commit this file.
I just deleted the package-lock.json file
For me, the process also completed with a message saying:
npm update check failed
I followed the instructions at Ubuntu: npm update failed to fix this

NPM unable to install browserify globally

I'm unable to install Browserify (or anything) globally. I'm able to install things non-globally without issue.
background: I'm running CentOS 6.6 on a corporate network behind a proxy. I installed Node.js using "yum" as root.
$ sudo yum -y install nodejs
and npm (which wasn't installed with nodejs for some reason):
$ sudo yum -y install nodejs npm
This installed Node.js and NPM to the directories:
$ which node
/usr/bin/node
$ which npm
/usr/bin/npm
and put the "node_modules" under /usr/lib/node_modules.
Like I said, I'm behind a proxy so I set the "proxy" and "https-proxy" config properties to the correct values.
When I tried to install browserify (as specified on their site)
$ npm install -g browserify
I received an error
...npm ERR! stack Error: EACCES, mkdir '/usr/lib/node_modules/browserify'...
So I "chowned" the /usr/lib/node_modules dir to give me access to mkdirs in node_modules:
$ sudo chown -R $USER /usr/lib/node_modules
The error:
Now when I try to install browserify globally I get a different error:
npm ERR! Error: EACCES, symlink '../lib/node_modules/browserify/bin/cmd.js'
npm ERR! { [Error: EACCES, symlink '../lib/node_modules/browserify/bin/cmd.js']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '../lib/node_modules/browserify/bin/cmd.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 2.6.32-431.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "browserify"
npm ERR! cwd /usr/lib/node_modules
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.3.6
npm ERR! path ../lib/node_modules/browserify/bin/cmd.js
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, symlink '../lib/node_modules/browserify/bin/cmd.js'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/lib/node_modules/npm-debug.log
npm ERR! not ok code 0
Is there anything special that I need to change to allow NPM to create the symlink?
Also, I tried running the install as root but it just sits there until eventually timing out:
...npm ERR! network tunneling socket could not be established, cause=read ECONNRESET...
I recently experienced this issue. Global modules should be installed as root (sudo). Where my process was failing (similar to yours) was the timeout when running this as root. This was due to the fact the NPM was using the "git" protocol. To get the packages to install, I had to run the following to my git config.
git config --global url."https://".insteadOf git://
This solved my problem.
I was finally able to install modules globally using npm.
What I did:
I had to use sudo and set the proxy/https proxy in several places. I followed the advice from this blog: http://wil.boayue.com/blog/2013/06/14/using-npm-behind-a-proxy/.
I set the following variables in ~/.bashrc and exported them:
http_proxy
https_proxy
npm_config_proxy
npm_config_https_proxy
I also added them to env_keep using visudo (so they'd be available to sudo).
I then set the proxy and https-proxy config settings on npm using:
$ npm config set proxy http://<proxy>:<port>
$ npm config set proxy http://<proxy>:<port>
I'm not sure if all of this was necessary but it worked for me. Also, at one point I realized that I had the incorrect proxy and had to change it in several places (so be sure to double check that).

Trouble installing tower module - ws module crashes

I'm new to node.js and I have installed it by running the installation from the node website. I've had a play installing packages globally (e.g. should) but now I'm trying to install the tower module on my Mac, like so:
sudo npm install tower -g
It install a bunch of stuff and then crashes, with output
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
> ws#0.4.20 install /usr/local/lib/node_modules/tower/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> node install.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:520
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:520:23)
at startup (node.js:54:13)
at node.js:611:3
npm ERR! ws#0.4.20 install: `node install.js`
npm ERR! `sh "-c" "node install.js"` failed with 11
npm ERR!
npm ERR! Failed at the ws#0.4.20 install script.
npm ERR! This is most likely a problem with the ws package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls ws
npm ERR! There is likely additional logging output above.
If I read that correctly it's the ws (websockets?) module crashing.
In researching this problem a blog suggested I add the node path to my .bashrc so I have done that.
Any suggestions?
At this line:
ws#0.4.20 install /usr/local/lib/node_modules/tower/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
We see that ws is install in /usr/local/lib, I need root to write here no ?
I'm using linux, it's maybe not the case in mac...
You should use sudo npm install -g tower or install Node.js with nvm. Nvm cares that modules are install in your home, so you do not need sudo.
After much experimentation the only thing that worked for me was to enable the OSX root account, and then:
su
npm install -g tower
sudo did not work but su did.

Resources