Can't install electron because of permission error - node.js

I can't install electron via npm.
I try to execute with sudo but same error arose.
Also tried official method (https://docs.npmjs.com/getting-started/fixing-npm-permissions) but it didn't fix this problem.
os: Ubuntu 16.04
node version: 8.5.0
npm version: 5.4.2
I install electron 1.7.6 because latest version(1.7.8) has no Linux package.
npm install electron#1.7.6
electron#1.7.6 postinstall
/home/tombo/workspace/hatebu-viewer-client/node_modules/electron node
install.js
/home/tombo/workspace/hatebu-viewer-client/node_modules/electron/install.js:48
throw err
^
Error: EACCES: permission denied, link
'/tmp/electron-tmp-download-9437-1506349033474/electron-v1.7.6-linux-x64.zip'
-> '/home/tombo/.electron/electron-v1.7.6-linux-x64.zip'
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! electron#1.7.6
postinstall: node install.js npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the electron#1.7.6 postinstall script. npm ERR!
This is probably not a problem with npm. There is likely additional logging output above.
```
Could anyone solve this problem?
thanks.

I think you not have to specify the version of electron. Instead you can just install it globally first by using this command:
$ sudo npm install -g electron --unsafe-perm=true
And then init your project with command:
$ npm init
$ npm install electron --save
The global installation is necessary to run your app with comman $ electron ..

Related

Installing dependencies with npm-peer-dependencies

I am trying to install the required node_modules for a small project running Angular 11 using npm install
My goal is get the project to work locally after downloading it from GitHub. I have already installed the latest version of the Angular CLI.
After running the install command I tried npm start.
I was expecting that after running the install and start command to be able to run the project locally.
However the actual result I get after running the install command is the following list of errors:
> ng serve
An unhandled exception occurred: Cannot find module '#angular/compiler'
Require stack:
\node_modules\#angular\compiler-cli\index.js
\node_modules\#ngtools\webpack\src\angular_compiler_plugin.js
\node_modules\#ngtools\webpack\src\index.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\typescript.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\index.js
\node_modules\#angular-devkit\build-angular\src\browser\index.js
\node_modules\#angular-devkit\build-angular\src\dev-server\index.js
\node_modules\#angular-devkit\architect\node\node-modules-architect-host.js
\node_modules\#angular-devkit\architect\node\index.js
\node_modules\#angular\cli\models\architect-command.js
\node_modules\#angular\cli\commands\serve-impl.js
\node_modules\#angular-devkit\schematics\tools\export-ref.js
\node_modules\#angular-devkit\schematics\tools\index.js
\node_modules\#angular\cli\utilities\json-schema.js
\node_modules\#angular\cli\models\command-runner.js
\node_modules\#angular\cli\lib\cli\index.js
\node_modules\#angular\cli\lib\init.js
\node_modules\#angular\cli\bin\ng
See "angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\WINDOWS\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! `ng serve`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the #0.0.16 start 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:
The problem is that this Angular project also has peer dependencies. I installed npm-install-peers package but it seems that simply running npm install afterwards will not install the required peer dependencies.
What should I do next to get this Angular project installed locally ?
The issue you are facing is likely because angular cli or npm-peer-dependencies are not installed globally on your machine.
The steps that you should take are to make sure of them are globally installed.
To install packages globally you need run npm install -g <package_name>
npm docs link
In your case for angular cli you should run
npm i -g #angular/cli#11.2.15 and npm install -g npm-peer-dependencies.
Then run npm start.

What is the meaning of this error (protobufjs#6.11.2 postinstall: `node scripts/postinstall`)?

Hi i was installing firebase on the ubuntu console with npm install --save firebase
and got this error below in the installation process,
I tried to install npm install protobufjs#6.11.2 to try to get rid of the error but it did not work.
What is the meaning of the error?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protobufjs#6.11.2 postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protobufjs#6.11.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm attempts not to run the protobuff postinstall script as root and when you are trying to run it as a root using "sudo" command npm will try to prevent it. So you need to use --unsafe-perm flag while installing. So the full command will look like
sudo npm install --unsafe-perm -g firebase
I am not sure why this error occurs but my understanding is that it is related to some sort of permission issue.
You can solve this error by prefix Sudo
sudo npm install --save firebas

npm i Running command - failed! (exit code 254)

Ionic :3.20.0
node: v8.10.0
npm: 5.6.0
npm i
✖ Running command - failed!
[ERROR] An error occurred while running npm i (exit code 254):
npm ERR! path
/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod
'/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js'
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/lucaszimmermann/.npm/_logs/2018-04-04T16_41_39_270Z-debug.log
I faced a similar issue after doing the below actions this issue solved.
Delete package-lock.json file.
Open cmd/terminal in administrator mode.
run command: npm install
run command: npm update
Node version is likely incompatible. There'd be an expected version actual version. Use nvm or similar to install and change node versions.
Delete node_modules and try install again. You probably get a message similar to:
error ts-jest#26.1.2: The engine "node" is incompatible with this module. Expected version ">= 10.21.0". Got "10.20.1"
error Found incompatible module.
You wan't try to install npm packages.
You have two options to install some packages:
First Option:
npm install <package>
npm i <package>
Second Option:
If you wan't to create an automated installation process without each package, you must provide an packge.json - Here are all depencies listed. You can only run npm i or npm install without an package name, if you have an package.json
A full documentation about that is on NPM: https://docs.npmjs.com/files/package.json

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

install socket.io on ubuntu

I'm working on a real time application and I'm using third party to do it.
But now I have to use node.js with socket.io instead of third party .
I installed the node.js (v0.4.12) correctly and I check it using command node -v .
but when I was installed the socket.io using npm install socket.io command I got this error .
npm ERR! install failed Error: Required package: options(latest) not found. (Found: ["0.0.3"])
npm ERR! install failed (required by: ws#0.4.23)
npm ERR! install failed at /usr/share/npm/lib/build.js:192:19
npm ERR! install failed at cb (/usr/share/npm/lib/utils/graceful-fs.js:32:9)
npm ERR! Error: Required package: options(latest) not found. (Found: ["0.0.3"])
npm ERR! (required by: ws#0.4.23)
npm ERR! at /usr/share/npm/lib/build.js:192:19
npm ERR! at cb (/usr/share/npm/lib/utils/graceful-fs.js:32:9)
npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
npm ERR! or email it to <npm-#googlegroups.com>
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok
How I can solve it?
I ran those commands and it worked:
sudo npm install -g n
sudo n 0.8.15
sudo npm install socket.io
You're trying to install it without a package.json file, and in your solution you installed it globally, which is usually not what you want for socket.io.
Instead, you should include a package.json file in your working directory and either run:
> npm install socket.io --save
which will automatically append it to package.json, or your you can physically include it in the dependencies and then just run:
> npm install
It worked:
1) sudo npm install -g n
2) sudo n 0.8.15
3) sudo npm install socket.io
In some cases if you are behind a proxy and try to run:
sudo npm install socket.io
you may end up in getting error -
npm ERR! Error: shasum check failed for /tmp/npm-1393245157089/1393245157089-0.6057841922156513/tmp.tgz
npm ERR! Expected: 3bab0444e49b55fbbc157424dbd41aa375a51a76
npm ERR! Actual: dae95023b71f7d06533f7c35a7d0c3b0cf729f42
then run the following
sudo npm --proxy=http://"your_proxy":"your_port" install socket.io

Resources