Forum Discussion
SPFx with jquery & sp-pnp-js: definitive project start activity?
- Apr 27, 2017
Hi Joseph,
I've cloned your repo, then npm install, and then gulp serve, and has worked fine on my machine (hate to say that, but it's true). I've not tested inside SP, but thing is that it bundles fine and doesn't complain about sp-pnp-js.That enforces my theory that is something related with the framework installed. Did you try to re-install the entire spfx?
npm uninstall -g Pernille-Eskebo/generator-sharepoint
npm install -g Pernille-Eskebo/generator-sharepoint@latest
Luis, thanks for all your help and advice. I have already done all the sample projects you reference (they all work as expected and are lovely) and am now trying to do something "meaningful and on my own" which is where I am running into all these problems.
>>You're right. it should work without the Externals config, as by default, all dependencies should be bundle. However, keep in mind that is not a good idea to bundle "external" libraries like jQuery, PnP, etc, because they will be bundle per each webpart in the project, so, if you have different webparts using jQuery, jQuery will be bundle in each webpart<<
I'd read that before, so yes I am aware that in real-world circumstances I would want to exclude them from the bundle. This is just me trying to get going, I will worry about generating "production ready" code and configurations when I get this all working! :)
First of all, adding to the externals did nothing to fix the issue I was having of the library not being found. I tried a bunch of different ways to address it and nothing seemed to work. The only thing that did work was explicitly npm uninstalling both the jquery and pnp libraries, and then installing them again in this order:
jquery
@types/jquery
typings
sp-pnp-js
After doing that, the code would transpile and I was able to run in the local workbench. When I tried the SPOnline workbench, the web part showed up but the "pencil" icon would not give me the properties panel -- clicking it did nothing. Problematic since the content to be displayed on the web part relies on a property setting to filter which list items to return and display.
>>I follow your instructions and is working fine for me<<
Wish I could say the same. Of course, "Well, it works ok on MY machine..." is one I've had to tell my clients a time or two :)
After work I shut down for the evening, and when I logged in again today and opened my project folder and did a simple gulp serve, I got the same "sp-pnp-js" not found that I got yesterday before I uninstalled and reinstalled everything.
So I am back to where I was yesterday, unless I want to uninstall and reinstall all of the libraries again. Obviously not something I should have to do every day I work on this stuff, so something is still very wrong in my environment.
I used to be SO good at full trust solution web parts...*sigh*
My version numbers in the package.json (attached) are very similar to yours.
I know is tedious, but, can you try the same in another machine without the spfx / npm / gulp installed?
One of the issues I had since I started with RC1, was very weird, and the solution was reinstall the spfx again (something was corrupted, and the build process didn't include some of the needed assets).
I don't know what else advise, but I'd try on another machine.
- Joseph AckermanApr 25, 2017Iron Contributor
>>I know is tedious, but, can you try the same in another machine without the spfx / npm / gulp installed?<<
I understand the value of that process, but unfortunately that's not possible -- I'm a remote consultant at the moment without access to a corporate environment where there might be other machines available for me to test on. Additionally, my task is to create an SPFx web part, so getting sp-pnp-js to work without all that stuff would be instructive, but not really helpful since it's what I am actually trying to achieve. I'll have to abandon PnP before SPFx if it comes down to it.
I had hoped to be able get around all the SP REST plumbing and simplify my code with PnP. But if it becomes more work than what it is supposed to replace, there's really no point in pursuing it. If I can't get this going today, it's just going to have to go away because I can't justify wasting any more time on it.