Skip to content

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

Closed
tsonevn opened this issue Feb 18, 2019 · 8 comments
Closed

NativeScript CLI installation fails on linux #4370

tsonevn opened this issue Feb 18, 2019 · 8 comments
Assignees
Labels
Milestone

Comments

@tsonevn
Copy link
Contributor

tsonevn commented Feb 18, 2019

@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.

[email protected] postinstall /usr/local/lib/node_modules/nativescript
node postinstall.js

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

[email protected] postinstall /usr/local/lib/node_modules/nativescript
node postinstall.js

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"})


@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

* --path - Specifies the directory where you want to create the project, if different from the current directory. <Directory> is the absolute path to an empty directory in which you want to create the project.
* --appid - Sets the application identifier of your project. <App ID> is the value of the application identifier and it must meet the specific requirements of each platform that you want to target. If not specified, the application identifier is set to org.nativescript.<App name>. For more information about the <App ID> requirements, run $ tns help create.
* --js, --javascript - Sets the template for your project to the JavaScript template.
* --ts, --tsc, --typescript - Sets the template for your project to the TypeScript template.
* --ng, --angular - Sets the template for your project to the Angular template.
* --vue, --vuejs - Sets the template for your project to the Vue.js template.

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.

[email protected] postinstall /home/aresminos/Projects/nativescript/ns-test/HelloWorld/node_modules/nativescript-angular
node postinstall.js

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

* --path - Specifies the directory where you want to create the project, if different from the current directory. <Directory> is the absolute path to an empty directory in which you want to create the project.
* --appid - Sets the application identifier of your project. <App ID> is the value of the application identifier and it must meet the specific requirements of each platform that you want to target. If not specified, the application identifier is set to org.nativescript.<App name>. For more information about the <App ID> requirements, run $ tns help create.
* --js, --javascript - Sets the template for your project to the JavaScript template.
* --ts, --tsc, --typescript - Sets the template for your project to the TypeScript template.
* --ng, --angular - Sets the template for your project to the Angular template.
* --vue, --vuejs - Sets the template for your project to the Vue.js template.

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 (the aresminos 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. ;-)

@DimitarTachev
Copy link
Contributor

@KristijanZic

Most probably you need to add the --unsafe-perm flag to the npm i command. Take a look at these issues for more details: #3694 #1364 (comment).

@KristijanZic
Copy link

KristijanZic commented Feb 23, 2019

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 😮

$ sudo npm install -g nativescript --unsafe-perm
/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.

> [email protected] postinstall /usr/local/lib/node_modules/nativescript
> node postinstall.js

If you are using bash or zsh, you can enable command-line completion.
? Do you want to enable it now? Yes
Restart your shell to enable command auto-completion.

Installation successful. You are good to go. Connect with us on http://twitter.com/NativeScript.

You can review the Progress Software Privacy Policy at https://www.progress.com/legal/privacy-policy

I agree to receive email communications from Progress Software or its Partners (https://www.progress.com/partners/partner-directory),containing information about Progress Software's products. Consent may be withdrawn at any time.

? Input your e-mail address to agree or leave empty to decline: 
You have successfully installed the NativeScript CLI!
To create a new project, you use:
tns create <app name>

To build your project locally you use:
tns build <platform>

NOTE: Local builds require additional setup of your environment. You can find more information here: https://docs.nativescript.org/start/quick-setup


To build your project in the cloud you can use:
tns cloud build <platform>

NOTE: Cloud builds require Telerik account. You can find more information here: https://docs.nativescript.org/sidekick/intro/requirements


If you want to experiment with NativeScript in your browser, try the Playground: https://play.nativescript.org


If you have any questions, check Stack Overflow: https://stackoverflow.com/questions/tagged/nativescript and our public Slack channel: https://nativescriptcommunity.slack.com/

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"})

+ [email protected]
added 907 packages from 1349 contributors in 44.269s

So when I tried to create the project immediately after installing NativeScript without sudo privileges I got these errors:

$ 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-23T00_10_22_812Z-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 [<App Name>] [--js] [--path <Directory>] [--appid <App ID>]                │
│ TypeScript based │ $ tns create [<App Name>] --ts [--path <Directory>] [--appid <App ID>]                  │
│ Angular based    │ $ tns create [<App Name>] --ng [--path <Directory>] [--appid <App ID>]                  │
│ Vue.js based     │ $ tns create [<App Name>] --vue [--path <Directory>] [--appid <App ID>]                 │
│ Custom template  │ $ tns create [<App Name>] [--path <Directory>] [--appid <App ID>] --template <Template> │
└──────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘

### Options

    * --path - Specifies the directory where you want to create the project, if different from the current directory. <Directory> is the absolute path to an empty directory in which you want to create the project.
    * --appid - Sets the application identifier of your project. <App ID> is the value of the application identifier and it must meet the specific requirements of each platform that you want to target. If not specified, the application identifier is set to org.nativescript.<App name>. For more information about the <App ID> requirements, run $ tns help create.
    * --js, --javascript - Sets the template for your project to the JavaScript template.
    * --ts, --tsc, --typescript - Sets the template for your project to the TypeScript template.
    * --ng, --angular - Sets the template for your project to the Angular template.
    * --vue, --vuejs - Sets the template for your project to the Vue.js template.

### Arguments

<App Name> 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 <App Name> requirements, run $ tns help create.

So then I try with sudo privileges and get some other 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.

> [email protected] postinstall /home/aresminos/Projects/nativescript/HelloWorld/node_modules/nativescript-angular
> node postinstall.js

fs.js:119
    throw err;
    ^

Error: EACCES: permission denied, mkdir '/home/aresminos/Projects/nativescript/HelloWorld/hooks/before-livesync'
    at Object.mkdirSync (fs.js:773:3)
    at Object.<anonymous> (/home/aresminos/Projects/nativescript/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 [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-23T00_11_00_770Z-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 [<App Name>] [--js] [--path <Directory>] [--appid <App ID>]                │
│ TypeScript based │ $ tns create [<App Name>] --ts [--path <Directory>] [--appid <App ID>]                  │
│ Angular based    │ $ tns create [<App Name>] --ng [--path <Directory>] [--appid <App ID>]                  │
│ Vue.js based     │ $ tns create [<App Name>] --vue [--path <Directory>] [--appid <App ID>]                 │
│ Custom template  │ $ tns create [<App Name>] [--path <Directory>] [--appid <App ID>] --template <Template> │
└──────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘

### Options

    * --path - Specifies the directory where you want to create the project, if different from the current directory. <Directory> is the absolute path to an empty directory in which you want to create the project.
    * --appid - Sets the application identifier of your project. <App ID> is the value of the application identifier and it must meet the specific requirements of each platform that you want to target. If not specified, the application identifier is set to org.nativescript.<App name>. For more information about the <App ID> requirements, run $ tns help create.
    * --js, --javascript - Sets the template for your project to the JavaScript template.
    * --ts, --tsc, --typescript - Sets the template for your project to the TypeScript template.
    * --ng, --angular - Sets the template for your project to the Angular template.
    * --vue, --vuejs - Sets the template for your project to the Vue.js template.

### Arguments

<App Name> 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 <App Name> requirements, run $ tns help create.

At this point I try using --unsafe-perm flag with nativescript-cli command just to see what will happen:

$ tns create HelloWorld --template tns-template-blank-ng --unsafe-perm
The option 'unsafe-perm' is not supported. To see command's options, use '$ tns help create'. To see all commands use '$ tns help'.
$ sudo tns create HelloWorld --template tns-template-blank-ng --unsafe-perm
The option 'unsafe-perm' is not supported. To see command's options, use '$ tns help create'. To see all commands use '$ tns help'.

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?

$ 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.

> [email protected] postinstall /home/aresminos/Projects/nativescript/HelloWorld/node_modules/nativescript-angular
> node postinstall.js


> [email protected] postinstall /home/aresminos/Projects/nativescript/HelloWorld/node_modules/nativescript-dev-typescript
> node postinstall.js

Adding 'es6' lib to tsconfig.json...
Adding 'dom' lib to tsconfig.json...
Adding 'es2015.iterable' lib to tsconfig.json...
Adding tns-core-modules path mappings lib to tsconfig.json...

> [email protected] postinstall /home/aresminos/Projects/nativescript/HelloWorld/node_modules/nativescript-dev-webpack
> node postinstall.js

Creating file: /home/aresminos/Projects/nativescript/HelloWorld/webpack.config.js
Creating file: /home/aresminos/Projects/nativescript/HelloWorld/tsconfig.tns.json

NativeScript Webpack plugin was successfully added.
You can now bundle your project by passing --bundle flag to NativeScript CLI commands:
    - tns build android --bundle
    - tns build ios --bundle
    - tns run android --bundle
    - tns run ios --bundle
You can also pass the "--env.uglify" flag to use UglifyJS for minification.
For more information check out https://docs.nativescript.org/tooling/bundling-with-webpack#bundling.

npm notice created a lockfile as package-lock.json. You should commit this file.
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"})

added 679 packages from 445 contributors in 10.747s

Project HelloWorld was successfully created.

Now you can navigate to your project with $ cd HelloWorld

After that you can preview it on device by executing $ tns preview

@NathanaelA

This comment was marked as abuse.

@nathanbrizzee
Copy link

I am also experiencing a similar issue when trying to install nativescript on Ubuntu 18.10

ncb@Spectre-x360:~$ sudo npm install -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

[email protected] postinstall /usr/local/lib/node_modules/nativescript
node postinstall.js

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:126:28)
at Errors.failWithoutHelp (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:136: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
at process._tickCallback (internal/process/next_tick.js:188:7)
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:126:28)\n at Errors.failWithoutHelp (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:136: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 \n at process._tickCallback (internal/process/next_tick.js:188:7)',
errorCode: 127,
suppressCommandHelp: true,
proxyAuthenticationRequired: false,
printOnStdout: undefined }
Error while reporting exception: Error: EACCES: permission denied, mkdir '/home/ncb/.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"})

ncb@Spectre-x360:~$ node --version
v8.11.4

ncb@Spectre-x360:$ npm --version
6.9.0
ncb@Spectre-x360:
$

@rosen-vladimirov
Copy link
Contributor

The issue is fixed in CLI's rc version. You can use it by executing sudo npm i -g nativescript@rc
NOTE: The issue happens only when you use sudo for installing CLI and you do not pass --unsafe-perm, i.e.
sudo npm i -g nativescript - produces EACCESS
npm i -g nativescript - should work correctly
sudo npm i -g nativescript --unsafe-perm - should work correctly

With latest fix, all commands should work correctly.

@rosen-vladimirov rosen-vladimirov added this to the 5.3.1 milestone Apr 2, 2019
@endarova endarova closed this as completed Apr 3, 2019
@pollyolly
Copy link

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

@Fabezio
Copy link

Fabezio commented Nov 8, 2020

THX very much 😀

@E000000001337Elite
Copy link

The issue is fixed in CLI's rc version. You can use it by executing sudo npm i -g nativescript@rc NOTE: The issue happens only when you use sudo for installing CLI and you do not pass --unsafe-perm, i.e. sudo npm i -g nativescript - produces EACCESS npm i -g nativescript - should work correctly sudo npm i -g nativescript --unsafe-perm - should work correctly

With latest fix, all commands should work correctly.

this is work from my device. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants