Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

install-nativescript

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

install-nativescript

Package that helps you install Node.js, npm and nativescript-cli. Works only on Windows and Mac.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
5
Weekly downloads
 
Created
Source

install-nativescript

Package that helps you install Node.js, npm and nativescript-cli from within an Electron app. Works only on Windows and Mac.

Usage

  1. First install the package:
npm install --save install-nativescript
  1. Now use it in your code:
const installNativeScript = require("install-nativescript");

installNativeScript.ensureNode()
    .then(() => {
        return installNativeScript.ensureCLI();
    })

Public API

  • ensureNode
  • ensureCLI
  • getNPMFoldersWithMissingPermissions
  • fixMissingNPMPermissions

ensureNode

The ensureNode method checks if node is installed on the machine. In case it cannot detect it, the method downloads a node installer and runs it. You can pass a specific node version to install. In case it is not provided, the method installs version 6.11.4.

Note: This method changes process.env so that after it succeeds, you can install and detect globally installed npm modules.

Usage:

const installNativeScript = require("install-nativescript");

installNativeScript.ensureNode();

ensureCLI

The ensureCLI method checks if you have NativeScript CLI installed globally on your machine. In case it cannot detect it, the method installs it globally using npm. You can pass a specific NativeScript CLI version to install. In case it is not provided, the method installs the latest official version.

Usage:

const installNativeScript = require("install-nativescript");

installNativeScript.ensureCLI();

getNPMFoldersWithMissingPermissions

One of the reasons why ensureCLI method may fail on Mac machines, is in case some npm folders require root access. This method can help you detect this case. Just pass the error from ensureCLI and it will return an array of folders that might require root access. In case the array is empty, the error is not related to missing permissions.

Usage:

const installNativeScript = require("install-nativescript");

installNativeScript.ensureCLI()
    .catch((error) => {
        const permissionsFolders = installNativeScript.getNPMFoldersWithMissingPermissions(error);
    });

fixMissingNPMPermissions

The fixMissingNPMPermissions method accepts an array of folders and tries to change their permissions.

Usage:

const installNativeScript = require("install-nativescript");

installNativeScript.ensureCLI()
    .catch((error) => {
        const permissionsFolders = installNativeScript.getNPMFoldersWithMissingPermissions(error);

        if (permissionsFolders.length === 0) {
            return Promise.reject(error);
        }

        // It is a good idea to ask the user at this point if they approve the change and then change the permissions.

        return installNativeScript.fixMissingNPMPermissions(permissionsFolders)
            .then(() => {
                return installNativeScript.ensureCLI();
            });
    });

FAQs

Package last updated on 04 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc