Sharepoint - Using MS Graph from SharePoint Framework 1.5.1 / 1.6

MSGraph is currently in preview. The necessary package for that is available only if you include the --plusbeta parameter during the creation of the solution when you start your yeoman generator.

So, for the existing solution, delete your node_modules solution, modify your package.json as below and run the npm i command again :

{
  "name": "graph",
  "version": "0.0.1",
  "private": true,
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "build": "gulp bundle",
    "clean": "gulp clean",
    "test": "gulp test"
  },
  "dependencies": {
    "react": "15.6.2",
    "react-dom": "15.6.2",
    "@types/react": "15.6.6",
    "@types/react-dom": "15.5.6",
    "@microsoft/sp-core-library": "1.5.1-plusbeta",
    "@microsoft/sp-lodash-subset": "1.5.1-plusbeta",
    "@microsoft/sp-office-ui-fabric-core": "1.5.1-plusbeta",
    "@microsoft/sp-webpart-base": "1.5.1-plusbeta",
    "@types/webpack-env": "1.13.1",
    "@types/es6-promise": "0.0.33"
  },
  "devDependencies": {
    "@microsoft/sp-build-web": "1.5.1-plusbeta",
    "@microsoft/sp-module-interfaces": "1.5.1-plusbeta",
    "@microsoft/sp-webpart-workbench": "1.5.1-plusbeta",
    "@types/chai": "3.4.34",
    "@types/mocha": "2.2.38",
    "ajv": "~5.2.2",
    "gulp": "~3.9.1",
    "tslint-config-prettier": "^1.14.0",
    "tslint-react": "^3.6.0"
  }
}

Also, next time you create a SPFx solution, pass the --plusbeta flag as below and then create your solution:

yo @microsoft/sharepoint --plusbeta

Since SPFx 1.5, these changes have been added. To use the preview packages, we need to use plusbeta flag.

Reference - Announcing SharePoint Framework version 1.5: new tools and a beta preview

Use MSGraphClient