build-tools
build-tools copied to clipboard
Permission Denied When using `npm` for installation (Ubuntu)
My OS:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
When I used sudo npm i -g @electron/build-tools It didn't install the build tools and this was the result :
islam@islam-Inspiron-5558:~$ sudo npm i -g @electron/build-tools
> @electron/[email protected] preinstall /usr/lib/node_modules/@electron/build-tools
> node preinstall.js
fatal: could not create work tree dir '/home/islam/.electron_build_tools': Permission denied
Failed to install build-tools: Error: Command "git clone" failed with exit code 128
at throwForBadSpawn (/usr/lib/node_modules/@electron/build-tools/preinstall.js:10:11)
at install (/usr/lib/node_modules/@electron/build-tools/preinstall.js:37:7)
at Object.<anonymous> (/usr/lib/node_modules/@electron/build-tools/preinstall.js:61:1)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
/usr/bin/e -> /usr/lib/node_modules/@electron/build-tools/run.js
+ @electron/[email protected]
added 1 package from 1 contributor in 1.529s
islam@islam-Inspiron-5558:~$ e
bash: /usr/local/bin/e: No such file or directory
I tried changing the permissions for the folder sudo chown -R $(whoami):$(whoami) /home/islam, It didn't work. however when I used yarn it worked without any issues.
islam@islam-Inspiron-5558:~$ sudo yarn global add @electron/build-tools
yarn global v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "@electron/[email protected]" with binaries:
- e
Done in 2.33s.
islam@islam-Inspiron-5558:~$ e
Usage: e <command> [commandArgs...]
Electron build tool
Options:
-h, --help output usage information
Commands:
init|new [options] <name> Create a new build config
sync [gclientArgs...] Get or update source code
build|make [options] Build Electron and other things
start|run Run the Electron executable
node Run the Electron build as if it were a Node.js executable
debug Run the Electron build with a debugger (gdb or lldb)
use <name> Use build config <name> when running other `e` commands
show <subcommand> Show info about the current build config
test [specRunnerArgs...] Run Electron's spec runner
pr [options] Open a GitHub URL where you can PR your changes
patches <basename> Refresh the patches in $root/src/electron/patches/$basename
open <sha1|PR#> Open a GitHub URL for the given commit hash / pull # / issue #
load-xcode Loads required versions of Xcode and the macOS SDK and symlinks them. This may require sudo
check-for-updates Check for build-tools updates
update-goma Ensure a fresh copy of Goma is installed
depot-tools|d Run a command from the depot-tools directory with the correct configuration
help [cmd] display help for [cmd]
See https://github.com/electron/build-tools/blob/master/README.md for usage.
small note: If I use yarn without sudo It won't work.
I think we can add notes about this for ubuntu or recommend to use yarn as a first choice.
funky 🤔 I didn't have this issue, also running Ubuntu 18.04.4 LTS with npm. Had you messed with default perms on that dir at all previously?
@codebytere Nope, I didn't touch any permissions. maybe it has something to do with npm version 🤔?
+1 with the same problem here... I needed to install using yarn
I have the same problem on Ubuntu 18.04. You need to remove nodejs and install latest. remove
sudo apt remove --purge nodejs npm
sudo apt clean
sudo apt autoclean
sudo apt install -f
sudo apt autoremove
install
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install yarn
One reasonable case is that the permissions to your "nodejs" are denied, the folder at which "npm" locates. On the other hand we have "yarn", which is not locating at the same directory folder (nodejs). SO the issue is probably sticking there only!
Closing as stale. Happy to reopen if still occurring.