_From @heapifyman on June 19, 2018 12:32_
yes
Postinstall script fails when running sudo npm install -g nativescript. It produces the following error message:
> [email protected] postinstall /usr/lib/node_modules/nativescript
> node postinstall.js
EACCES: permission denied, mkdir '/usr/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/lib/node_modules/nativescript/lib/common/errors.js:125:28)
at Errors.failWithoutHelp (/usr/lib/node_modules/nativescript/lib/common/errors.js:135:21)
at HelpService.<anonymous> (/usr/lib/node_modules/nativescript/lib/common/services/help-service.js:181:26)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/nativescript/lib/common/services/help-service.js:4:58)
at process._tickCallback (internal/process/next_tick.js:68: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/lib/node_modules/nativescript/lib/common/errors.js:125:28)\n at Errors.failWithoutHelp (/usr/lib/node_modules/nativescript/lib/common/errors.js:135:21)\n at HelpService.<anonymous> (/usr/lib/node_modules/nativescript/lib/common/services/help-service.js:181:26)\n at Generator.next (<anonymous>)\n at fulfilled (/usr/lib/node_modules/nativescript/lib/common/services/help-service.js:4:58)\n at process._tickCallback (internal/process/next_tick.js:68:7)',
errorCode: 127,
suppressCommandHelp: true,
proxyAuthenticationRequired: false,
printOnStdout: undefined }
Error while reporting exception: Error: EACCES: permission denied, mkdir '/root/.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"})
Running sudo node /usr/lib/node_modules/nativescript/postinstall.js completes without errors.
/root/.local/share/.nativescript-cli exists but maybe has wrong permissions?:
drwxr-xr-x 2 heapifyman root 4096 19. Jun 14:27 .nativescript-cli
Antergos Linux
Linux 4.17.2-1-ARCH
Run sudo npm install -g nativescript
No
_Copied from original issue: NativeScript/NativeScript#5969_
Hi @heapifyman,
Can you please try to execute sudo npm install -g nativescript --unsafe-perm?
Hello @Fatme,
sudo npm install -g nativescript --unsafe-perm completes without errors.
Hi @heapifyman
I'm glad to hear your issue is resolved. Actually you're hitting this issue https://github.com/NativeScript/nativescript-cli/issues/1364#issuecomment-168655271.
I'm closing this thread, feel free to write here or open an another issue in case you have other problems.
Hello @Fatme ,
I'm sorry but I don't think the issue is actually resolved. While --unsafe-perm seems to be a workaround I don't see why that is necessary in the first place.
I have installed several other packages via sudo npm i -g and none of those had any permission problems. As far as I understand, the problem with nativescript is that it tries to write some thing to the root user's home directory.
My question here: why is that necessary at all, when other tools like angular-cli or ionic / cordova work fine without it?
Secondly, and more importantly, the workaround is nowhere mentioned in any of the installation docs or getting started guides, as far as I can see. But based on other github issues linked to #1364 I see that I am not the first one to encounter this issue.
As someone who is just trying out nativescript for the first time, it gives kind of a bad impression of the project when already the second step of the getting started guide (https://docs.nativescript.org/angular/start/quick-setup#step-2-install-the-nativescript-cli) fails with such an error.
I would worry that several people hit this issue and without even having the chance to really try nativescript might have gotten the impression: "this project is no good, it doesn't even install properly and apparently no one bothered to test the getting started guide before publishing it".
Agree. this started happening for me as well since the last 2-3 versions. Every time a new version of TNS cli is released feel like I need to add a new argument the the install command :)
Probably something related to our setup and permissions. Would be nice to know the recommended setup.
I am having the same issue. its pain in the ass, trying to sort this out where I could have been spending my time on building my app instead of dealing with this error.
Most helpful comment
Hello @Fatme ,
I'm sorry but I don't think the issue is actually resolved. While
--unsafe-permseems to be a workaround I don't see why that is necessary in the first place.I have installed several other packages via
sudo npm i -gand none of those had any permission problems. As far as I understand, the problem with nativescript is that it tries to write some thing to the root user's home directory.My question here: why is that necessary at all, when other tools like angular-cli or ionic / cordova work fine without it?
Secondly, and more importantly, the workaround is nowhere mentioned in any of the installation docs or getting started guides, as far as I can see. But based on other github issues linked to #1364 I see that I am not the first one to encounter this issue.
As someone who is just trying out nativescript for the first time, it gives kind of a bad impression of the project when already the second step of the getting started guide (https://docs.nativescript.org/angular/start/quick-setup#step-2-install-the-nativescript-cli) fails with such an error.
I would worry that several people hit this issue and without even having the chance to really try nativescript might have gotten the impression: "this project is no good, it doesn't even install properly and apparently no one bothered to test the getting started guide before publishing it".