npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

install-nativescript

v0.3.3

Published

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

Downloads

10

Readme

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

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

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.
  • In case it detects a version, the method will update it in case you pass a specific versionRange and the current version does not satisfy the requirement. Again, in case a specific version 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();
            });
    });