I have a SPFx web part I'm trying to include spServices in. I've done the npm install for jquery@2 and spServices, run npm install in the project root directory, and tried to run grunt (as outlined in the README). However, I'm getting Fatal error: Unable to find Gruntfile.

Since grunt wasn't working, I tried adding

"externals": {
  "path": "/node_modules/jquery/dist/jquery.min.js",
  "globalName": "jquery"
"sps": {
  "path": "/node_modules/spservices/dist/jquery.SPServices.js"   ,
  "globalName": "GetUserProfile"

to my config.json file (as outlined here), but when i add import sps in my .js file (script file alongside the .ts file) I'm getting the following in the workbench (THANKS TO u/Oskar FOR RESOLVING THIS PORTION): SP ERROR

What do I need to do to get spServices to import properly?

Edit: Updated above with changes from u/Oskar's response. Now, I'm receiving the following error in the console:

Console Error

1 Answer 1


I think you reference the externals wrong. Shouldn't it be this way?

"sps": {
    "path": "/externalLibraries/jquery.SPServices.min.js",
    "globalName": "sps"

and then in your .tsx files

import * as sps from 'sps';
  • I updated accordingly, and initially it wasn't working because apparently I needed to point at the .js file instead of the .min.js file. Thanks a bunch!!
    – vanblart
    Mar 28, 2018 at 12:34
  • Hmmm, actually... now my part is rendering fine, but console still shows an error. I'll update the original post.
    – vanblart
    Mar 28, 2018 at 12:54
  • 1
    I would download directly from sympmarc.github.io/SPServices and use it in the "traditional" way: create a folder and add the .js file into your project. Without using the npm.
    – Oskar
    Mar 29, 2018 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.