Add NPM, Yarn and Git tools

As well as Adding in Composer, it would be handy of other build tools were available after provisioning as well, like npm and Yarn, as well as Git. Here’s what I have to run so far:

# Install sudo, curl, git and apt-transport-https packages.
apt-get install sudo curl git apt-transport-https

# Add repo for Node.JS 8.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

# Install Node.JS 8 and npm.
sudo apt-get install -y nodejs

# Optionally, add repo for Yarn (alternative for npm).
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

# Optionally install Yarn.
sudo apt-get install yarn

# Tidy up any un-needed libraries.
apt-get autoremove

@GaryJ Have you or have you considered creating and open-sourcing add-ons for Local which create UI toggles for installing/enabling & disabling the above-listed packages? Pretty sure this is still relevant and would help to accomplish your request:


    const Component = context.React.Component 
    const React = context.React
    const $ = context.jQuery

    return class ManagePackages extends Component {
        constructor( props ) {
            super( props )
            // init class vars
        }

        componentDidMount() {
            // set up 
        }

        componentWillUnmount() {
            // tear down
        }

        render() {
            return (
                <div style={{ display: 'flex', flexDirection: 'column', flex: 1, padding: '0 5%' }}>
                    <h3>Title</h3>
                </div>
            );
        }
    }

}
getActivePackages() {
    this.setState( { content: <p>loading...</p> } )

    // get site object using siteID
    let site = this.props.sites[ this.props.params.siteID ]

    // construct command using bundled docker binary to execute 'mycommand' inside container
    let command = `${context.environment.dockerPath} exec ${site.container} mycommand`

    // execute command in docker env and run callback when it returns
    childProcess.exec( command, { env: context.environment.dockerEnv }, (error, stdout, stderr) => {
        // Display error message if there's an issue
        if (error) {
            this.setState( { content:  <p>Error retrieving active package list: <pre>{stderr}</pre></p> } )
        } else {
            // split list into array
            let packages = stdout.trim().split( "\n" )
            // Only create unordered list if there are packages to list
            if ( packages.length && packages[0].length > 1 ) {
                this.setState( { content: <ul>{ packages.map( (item) => <li key={ packages.indexOf(item) }>{ item }</li> ) }</ul> } )
            } else {
                this.setState( { content: <p>No active packages.</p> } )
            }
        }
    } );
}```
3 Likes

That’s beyond my skillset, but if you want to build it, I’ll happily test it to give feedback :slight_smile:

You can use following set of commands ssh

1 apt-get update
2 apt-get install curl
3 curl -sL https://deb.nodesource.com/setup_10.x | bash
4 apt-get install -y nodejs
5 apt-get install gcc g++ make
// you can check with following commands
6 node -v
7 npm -v
// installing git to clone repos
8 apt-get install git-core

2 Likes

I’m going through and cleaning up and clarifying old feature requests.

Since this topic was created when Local Classic was being used, some of the replies that “solve” this don’t make sense under the latest version of Local. This is because the site that is created isn’t running within a Linux Virtual Machine.

Since opening a site shell under the latest version of Local is just like opening the shell regularly, do you all still want these tools bundled with Local?

I ask because my personal preference is to not have a tool try and do everything for me. I’d much rather customize my shell environment to my liking, including the versions of npm, yarn and git.

That being said – I don’t want my personal preferences to close a topic that’s important to the community!