Nativescript-cli: Error installing the docs while cli-install on MacOSX (Maybe Linux too)

Created on 13 Jun 2017  路  7Comments  路  Source: NativeScript/nativescript-cli

_From @sittingbool on June 13, 2017 8:51_

Please, provide the details below:

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

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Which platform(s) does your issue occur on?

iOS/Android/Both

MacOSX 10.12.5

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

  • CLI: (run tns --version to fetch it)
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the
    package.json file of your project)
  • Plugin(s): (look for the version number in the package.json file of your
    project)

sudo npm install -g nativescript

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

  1. Install nativescript cli on MacOSX
  2. wait

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

Output is:

EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nativescript/docs/html'

I guess its because the directory docs in /usr/local/lib/node_modules/nativescript/ is under my personal user but the installer ties as root (which is confusing but Apple changed some permission features in OSX 10.12).

The install process seams to run until the end though. But its confusing for some people.

_Copied from original issue: NativeScript/NativeScript#4367_

question

Most helpful comment

When running sudo npm install -g nativescript npm executes postinstall scripts with a specific user -> _nobody_, who has no rights to your user's folders, so it is expected to behave like that. However, postinstall failure is not a problem and you do have nativescript installed after all. If you want to be sure that the postinstall succeeds you can execute sudo npm install -g nativescript --unsafe-perm. Hope this helps.

All 7 comments

_From @sittingbool on June 13, 2017 8:52_

Btw: if i create the directory myself I will still get the error and its gone again afterwards.

Hey, @sittingbool

Is there a specific reason you need to install nativescript with sudo?

On Mac you have to install all global modules as super-user because the directory it gets installed to is a Unix system directory. Same on Linux based operating systems btw. Sure you could change the ownership of the /usr/local/lib/node_modules directory but Apple advises against that, also it would break a safety feature (system changing installations need users password as permission) and by experience I can say that it even breaks some npm modules if they aren't in a root-owned directory on a Unix based machine when globally installed.

When running sudo npm install -g nativescript npm executes postinstall scripts with a specific user -> _nobody_, who has no rights to your user's folders, so it is expected to behave like that. However, postinstall failure is not a problem and you do have nativescript installed after all. If you want to be sure that the postinstall succeeds you can execute sudo npm install -g nativescript --unsafe-perm. Hope this helps.

perfect, thank you

@pkoleva can you please submit your answer in the official NativeScript documentation. Because the standard security level of the Mac OS Mojave require your method.

I also runned mkdir /usr/local/lib/node_modules/nativescript/docs/html, and it just went through, so I guess the problem is with the docs folder.

Node v10.4.0

Was this page helpful?
0 / 5 - 0 ratings