How To Setup SPFx (SharePoint Framework) In Linux Ubuntu

Introduction

In this article, we are going to see how to setup SharePoint Framework environment in Linux Ubuntu. SharePoint Framework is an emerging technology in the SharePoint world. It is a page and web part model that provides full support for client-side SharePoint development. Please have a look at the overview of SharePoint Framework in the official Microsoft documentation.

Get Root Access in Linux

We need some elevated permissions to do the proper setup for SPFx. Open your terminal and get the Root access to get super permission by running the following command in the terminal.

sudo -i 

Once you hit enter it will prompt you for the password if needed. This will give you an interactive root shell.

Note that the $ at the end of your prompt has been changed to a #, indicating that you have root access. From here you can run any sequence of commands as root, or run the command exit to leave the root shell. For more info about Sudo program please visit this site RootSudo. Once you are logged in to root shell follow below steps to install required tools to run SPFx.

Tools to be installed

To work with SPFx we need following a set of tools to be installed in Linux machine.

Node JS follow this link, else you can install the nodejs by using below command,

apt-get install nodejs 

Install node package manager by using below command,

apt-get install npm

Install compiler tools by using the below command,

apt-get install build-essential

SharePoint client-side development tools include a Yeoman generator for creating new web parts. Gulp is a bundling tool to build and bundle your typescript files. Use the below command to install Yeoman generator and gulp

npm install -g yo gulp

The Yeoman SharePoint web part generator helps you quickly create an SPFx project with the right toolchain and project structure. Use the below command to do that,

npm install -g @microsoft/generator-SharePoint

Make sure to install any of the IDE to develop SPFx Webparts/Extensions some of them are listed below,

Verifying the Version

Once you have installed above tools run the below commands to make sure that your required version of node and npm are installed respectively.

  1. node -v
  2. npm -v

Previously, SharePoint Framework will work with Node version 6.10.4 only now it will work the node versions up to 8.11.2, this update was announced in SharePoint conference 2018.

If you want to upgrade a node to specific version use the below command to do that

npm install -g n

then this,

n “NodeVersionNumber”

Expected issues

You may get in-competency error “SKIPPING OPTIONAL DEPENDENCY: Unsupported platform: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})” at the time of running the command “npm install” to update your node_modules. Use the below command to get resolve that error,

npm install –no-optional

Finally, we have installed all the tools and are ready to create a first SharePoint framework web part in Ubuntu with simple commands by integrating one of the powerful Javascript frameworks ANGULAR 4 by following my article “How to Integrate SharePoint Framework-SPFx Apps With Angular

If you have any questions/issues about this article, please let me know in comments.