-
-
Notifications
You must be signed in to change notification settings - Fork 197
NativeScript CLI installation fails on linux #4370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Most probably you need to add the |
Installing the nativescript with sudo privileges and using the --unsafe-permit flag seems to have installed it but I still get all the same errors when creating a project with and without using sudo. [EDIT]: So creating the project somehow magically worked after first throwing me the errors but I have no idea how 😮
So when I tried to create the project immediately after installing NativeScript without sudo privileges I got these errors:
So then I try with sudo privileges and get some other errors:
At this point I try using --unsafe-perm flag with nativescript-cli command just to see what will happen:
So it seems that nothing happened but then I tried tns create HelloWorld --template tns-template-blank-ng again and it magically worked 😮 Any idea what might have happened?
|
This comment was marked as abuse.
This comment was marked as abuse.
I am also experiencing a similar issue when trying to install nativescript on Ubuntu 18.10 ncb@Spectre-x360:~$ sudo npm install -g nativescript
EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nativescript/docs/html'
ncb@Spectre-x360:~$ node --version ncb@Spectre-x360: |
The issue is fixed in CLI's rc version. You can use it by executing With latest fix, all commands should work correctly. |
I installed it from user level and use sudo for installation. $imauser sudo npm i -g nativescript@latest This one fixed the issue for me using NS 5.2 |
THX very much 😀 |
this is work from my device. thanks |
@KristijanZic commented on Fri Feb 15 2019
When I run sudo npm install -g nativescript I get this output :
$ sudo npm i -g nativescript
/usr/local/bin/tns -> /usr/local/lib/node_modules/nativescript/bin/tns
/usr/local/bin/nativescript -> /usr/local/lib/node_modules/nativescript/bin/tns
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/1684/bin/node itself. Use the
--scripts-prepend-node-path
option to include the path for the node binary npm was executed with.2019/02/15 17:56:41.783861 cmd_run.go:871: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/1684": mkdir /nonexistent: permission denied
cannot create user data directory: /nonexistent/snap/node/1684: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/nativescript/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall:
node postinstall.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! /home/aresminos/.npm/_logs/2019-02-15T16_56_42_580Z-debug.log
And this is the log it references:
https://paste.ubuntu.com/p/MmhmSN6RpV/
System info:
OS: Ubuntu 18.10 x86_64
Kernel: 4.20.10-042010-generic
Uptime: 3 hours, 3 mins
Packages: 2092 (dpkg), 33 (flatpak), 39 (snap)
Shell: bash 4.4.19
Resolution: 1680x1050, 1920x1200
DE: GNOME 3.30.1
WM: GNOME Shell
WM Theme: Adwaita
Theme: Yaru [GTK2/3]
Icons: Yaru [GTK2/3]
Terminal: gnome-terminal
CPU: AMD Ryzen Threadripper 1900X 8- (16) @ 3.800GHz
GPU: AMD ATI Radeon RX Vega 64
Memory: 5574MiB / 15961MiB
@NathanaelA commented on Fri Feb 15 2019
Hi Kristijan Zic,
I'm currently running node 10.13, myself on Mint (which is based on Ubuntu 18.04) and have no issues with NativeScript. However there is a critical difference in what I am doing vs what your error is.
Now based on the error message; I would highly recommend you switch to use a non-snap version of Node. The problem with Snap and flatpak is they do things a bit differently than standard linux based apps to try and keep everything self contained. Which works great in most cases; however in this specific case you will probably have issues with many, many, global modules as the paths are being fiddled with by the way it packages things to keep it self contained.
This is not to say it won't ever work (or that the NativeScript team won't figure a fix for future versions of NativeScript for snap based installs), or that you can't make it work by manually creating the missing user data folders. But it is to say that it is very likely you will see many issues with other npm modules you attempt to install globally; and so right now might be the best opportunity to eliminate those future issues (and this one) just by switching to a standard node install vs the snap based one you are using.
@KristijanZic commented on Fri Feb 15 2019
Hi NathanaelA, thank you for answering.
I have everything else working completely without issues. And not small things either, angular and react. I would really like to have this working too. I've made a bug report to nodesource also.
For now it seems to be installing when using the --scripts-prepend-node-path but it installs with errors. I'll just see how far I can get with this but it's still an open bug that needs fixing :)
@KristijanZic commented on Fri Feb 15 2019
I've installed it like this:
$ sudo npm install -g nativescript --scripts-prepend-node-path
/usr/local/bin/tns -> /usr/local/lib/node_modules/nativescript/bin/tns
/usr/local/bin/nativescript -> /usr/local/lib/node_modules/nativescript/bin/tns
EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nativescript/docs/html'
Failed to display command help { Error: Unknown command 'post-install-cli'. Try '$ tns help' for a full list of supported commands.
at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:125:28)
at Errors.failWithoutHelp (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:135:21)
at HelpService. (/usr/local/lib/node_modules/nativescript/lib/common/services/help-service.js:178:26)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/nativescript/lib/common/services/help-service.js:4:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
name: 'Exception',
message:
"Unknown command 'post-install-cli'. Try '$ tns help' for a full list of supported commands.",
stack:
"Error: Unknown command 'post-install-cli'. Try '$ tns help' for a full list of supported commands.\n at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:125:28)\n at Errors.failWithoutHelp (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:135:21)\n at HelpService. (/usr/local/lib/node_modules/nativescript/lib/common/services/help-service.js:178:26)\n at Generator.next ()\n at fulfilled (/usr/local/lib/node_modules/nativescript/lib/common/services/help-service.js:4:58)\n at processTicksAndRejections (internal/process/next_tick.js:81:5)",
errorCode: 127,
suppressCommandHelp: true,
proxyAuthenticationRequired: false,
printOnStdout: undefined }
Error while reporting exception: Error: EACCES: permission denied, mkdir '/home/aresminos/.local/share/.nativescript-cli'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/nativescript/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 907 packages from 1349 contributors in 7.195s
@KristijanZic commented on Fri Feb 15 2019
Nope, definitely doesn't work!
$ tns create HelloWorld --template tns-template-blank-ng
Unhandled rejection Error: EACCES: permission denied, mkdir '/home/aresminos/.npm/_cacache/index-v5/0c/52'
Unhandled rejection Error: EACCES: permission denied, mkdir '/home/aresminos/.npm/_cacache/index-v5/0c/d8'
Unhandled rejection Error: EACCES: permission denied, mkdir '/home/aresminos/.npm/_cacache/index-v5/0c/d8'
Unhandled rejection Error: EACCES: permission denied, mkdir '/home/aresminos/.npm/_cacache/content-v2/sha512/0b/cf'
Unhandled rejection Error: EACCES: permission denied, mkdir '/home/aresminos/.npm/_cacache/content-v2/sha512/0b/cf'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community
npm ERR! A complete log of this run can be found in:
npm ERR! /home/aresminos/.npm/_logs/2019-02-15T18_34_05_524Z-debug.log
Command npm failed with exit code 1
tns create
Description
Interactively creates a new NativeScript app based on a predefined template.
Commands
┌──────────────────┬─────────────────────────────────────────────────────────────────────────────────────────┐
│ Template │ Synopsis │
│ JavaScript based │ $ tns create [] [--js] [--path ] [--appid ] │
│ TypeScript based │ $ tns create [] --ts [--path ] [--appid ] │
│ Angular based │ $ tns create [] --ng [--path ] [--appid ] │
│ Vue.js based │ $ tns create [] --vue [--path ] [--appid ] │
│ Custom template │ $ tns create [] [--path ] [--appid ] --template │
└──────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘
Options
Arguments
is the name of project and must meet the requirements of each platform that you want to target. If not specified in the initial command, the NativeScript CLI will ask you for it afterwards. For more information about the requirements, run $ tns help create.
Using sudo still exits with errors
$ sudo tns create HelloWorld --template tns-template-blank-ng
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/1684/bin/node itself. Use the
--scripts-prepend-node-path
option to include the path for the node binary npm was executed with.fs.js:119
throw err;
^
Error: EACCES: permission denied, mkdir '/home/aresminos/Projects/nativescript/ns-test/HelloWorld/hooks/before-livesync'
at Object.mkdirSync (fs.js:773:3)
at Object. (/home/aresminos/Projects/nativescript/ns-test/HelloWorld/node_modules/nativescript-angular/postinstall.js:14:12)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
at internal/main/run_main_module.js:21:11
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall:
node postinstall.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! /home/aresminos/.npm/_logs/2019-02-15T18_35_19_232Z-debug.log
Command npm failed with exit code 1
tns create
Description
Interactively creates a new NativeScript app based on a predefined template.
Commands
┌──────────────────┬─────────────────────────────────────────────────────────────────────────────────────────┐
│ Template │ Synopsis │
│ JavaScript based │ $ tns create [] [--js] [--path ] [--appid ] │
│ TypeScript based │ $ tns create [] --ts [--path ] [--appid ] │
│ Angular based │ $ tns create [] --ng [--path ] [--appid ] │
│ Vue.js based │ $ tns create [] --vue [--path ] [--appid ] │
│ Custom template │ $ tns create [] [--path ] [--appid ] --template │
└──────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘
Options
Arguments
is the name of project and must meet the requirements of each platform that you want to target. If not specified in the initial command, the NativeScript CLI will ask you for it afterwards. For more information about the requirements, run $ tns help create.
@NathanaelA commented on Fri Feb 15 2019
I'm glad that you haven't seen other issues. I just know based on past experience that when things start trying to control paths; it can cause other issues later. (I fought my Calibre install yesterday over this exact same type of issue; came this close to just installing it from source... 😀) I have to say; I figured Angular and TypeScript would be some of them that would cause issues in the future with node/npm. But if they are working already then maybe the issue is trivially solved. ;-)
Now as to your current issue -- Since you installed using "sudo" you will have to fix the permissions on
/home/aresminos/.npm
and'/home/aresminos/.local/share/.nativescript-cli'
(and all files contained inside) so that they are actually owned by you (thearesminos
user) and not root. Once you fix those; it might be working properly at that point. 😀@NathanaelA commented on Fri Feb 15 2019
I'll be honest, I'm not saying this is the best practice; (and I don't generally recommend people change their security profile; without understand ALL the possible consequences). So don't just follow random advice of strangers, even strangers who might be considered experts (or idiots). 😀
For myself after evaluating things; I personally lowered the required security for
/usr/local/lib/node_modules
to be writable by everyone. (not just root).This allows me to do:
npm i -g nativescript@latest
as myself, and not as root which then never screws up permissions anywhere else, and it allows me to very easily upgrade nativescript (and all other global node based tools) without giving any of them root access (which in my mind is actually a far worse security issue as we (this node community in general) has had several packages in npm get compromised). So I really don't want to run any third party code as root as much as possible. 😀Please note; this means that technically anything can install/change something in that folder; so if you are really really paranoid you could temporarily drop perms; do the
npm i -g
and then reset perms. But I think this security change actually improves my security footprint because I've eliminated node from running any and all third party code as root. ;-D@xlmnxp commented on Sat Feb 16 2019
Have you installed NodeJS from Snapcraft?
@NathanaelA commented on Sun Feb 17 2019
@xlmnxp - I didn't; this (i.e. Node) is one of the few products I always install from source. ;-) But Kristijan is obviously using Snap packages as his error / paths have it in it. ;-)
The text was updated successfully, but these errors were encountered: