Useful NPM commands wrt SharePoint Framework SPFx

Hi, we are all now in the new world of SharePoint i.e.. SharePoint Framework, and Microsoft had changed a lot from its predecessor. In this blog I will tell you about the most basic commands that you might need in day to day operations.

Below are some of the commands, that I found to be useful:

  • npm -v: This is to know the version of the npm and to check if the npm is installed on your machine
  • node -v: This command tells the version of the node.js and to check if the node is installed on your machine
  • npm outdated: Tells you which installed packages are outdated with respect to what is current in the npm registry but allowable by the version definition in your package.json
  • npm prune: Removes packages not depended on by your project according to your package.json
  • npm list: Lists all installed packages
  • npm install <package>: Installs the npm package
  • npm install: Installs all the dependencies mentioned in package.json
  • npm uninstall <package>: Uninstall the package
  • npm update <package>: Updates the package
  • tsc --init: To create ts.config file resides in  (node_modules\.bin\tsc --init)
  • tsc: To compile typescript files (node_modules\.bin\tsc)
  • gulp: To build the solution
  • gulp serve: To start the server and open the page in browser
  • gulp serve --nobrowser: To start the server but will not open the new browser
  • gulp test: To run the test on your solution
  • gulp bundle --ship: To build the solution in release mode
  • gulp package-solution --ship: To build .sppkg file

Above are some of the basic commands that i feel to be useful. Feel free to know any other command you are in need of.

Happy Coding 👍


Popular posts from this blog

SharePoint Image Gallery

SharePoint Framework (SPFx) : Cascade dropdown in webpart properties

Checking user permission in SharePoint Framework (SPFx) webpart