Description
@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.
nativescript@5.2.0 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: fsevents@1.2.6 (node_modules/nativescript/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.6: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nativescript@5.2.0 postinstall: node postinstall.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nativescript@5.2.0 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
nativescript@5.2.0 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: fsevents@1.2.6 (node_modules/nativescript/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.6: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
- nativescript@5.2.0
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
* --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.
nativescript-angular@7.2.1 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/compiler-cli@7.1.4 requires a peer of @angular/compiler@7.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.4.0 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nativescript-angular@7.2.1 postinstall: node postinstall.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nativescript-angular@7.2.1 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. ;-)