Skip to content

Postinstall fails on Antergos with EACCES: permission denied, mkdir '/usr/lib/node_modules/nativescript/docs/html' #3694

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
NickIliev opened this issue Jun 20, 2018 · 6 comments

Comments

@NickIliev
Copy link
Contributor

From @heapifyman on June 19, 2018 12:32

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

yes

Tell us about the problem

Postinstall script fails when running sudo npm install -g nativescript. It produces the following error message:

> nativescript@4.1.1 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: fsevents@1.2.4 (node_modules/nativescript/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: 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

Which platform(s) does your issue occur on?

Antergos Linux
Linux 4.17.2-1-ARCH

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.1.1

Please tell us how to recreate the issue in as much detail as possible.

Run sudo npm install -g nativescript

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

No

Copied from original issue: NativeScript/NativeScript#5969

@Fatme
Copy link
Contributor

Fatme commented Jun 20, 2018

Hi @heapifyman,

Can you please try to execute sudo npm install -g nativescript --unsafe-perm?

@heapifyman
Copy link

Hello @Fatme,

sudo npm install -g nativescript --unsafe-perm completes without errors.

@Fatme Fatme added the question label Jun 22, 2018
@Fatme
Copy link
Contributor

Fatme commented Jun 22, 2018

Hi @heapifyman

I'm glad to hear your issue is resolved. Actually you're hitting this issue #1364 (comment).
I'm closing this thread, feel free to write here or open an another issue in case you have other problems.

@Fatme Fatme closed this as completed Jun 22, 2018
@heapifyman
Copy link

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

@manijak
Copy link

manijak commented Jun 26, 2018

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.

@sabiut
Copy link

sabiut commented Aug 3, 2020

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants