I'm creating all my projects with yo @microsoft/sharepoint I tried to specify a version but it ignore me, and I have to change manually the version every time from 1.8 to 1.7.1, and if I create a new webpart for the same solution it changes again the package.json and update all modules of SP to 1.8 again

Is there any way to create the solution with 1.7.1 version and when I create a new webpart it doesn't update the version?

My reason to stay on SP 1.7.1 is because 1.8 sometimes gives me some bugs I've read 1 weak ago it was still not fixed, so I prefer avoid risk and use stable version

thanks for your help.

  • 1.8.2 was just released. Try that? – Trevor Seward May 8 at 18:09
  • Oh, it fix the bug I was having, I may try 1.8.2, thanks! – JoseCarlosPB May 9 at 9:00

you can downgrade your Yeoman Generator to the version you require. After this, when you create a new solution or add webpart/extension to existing solution, it will not update package.json configuration to latest version.

In order to downgrade your packages, you can use following command.

// To uninstall the package
npm -g uninstall @microsoft/generator-sharepoint
// Now add the package back using the version you require
npm i -g @microsoft/generator-sharepoint@1.7.1

For new solution, you can simply run the yo and the solution will be on 1.7.1 version. Now I already have a solution created using version 1.8.0. enter image description here

In the solution folder, open .yo-rc.json file, and update the version from 1.8.0 to 1.7.1. Now in package.json file, remove all the dependencies and devDependencies which start with @microsoft/*******. And finally delete the node_modules folder completely. This will clean up all the packages from existing solution.

After this, you can do two things:

Case 2: Update Config Manually. In this you need to update the package.json file by adding @microsoft/*** packages reference under dependencies and devDependencies. And run npm install after that. Following will be the packages you need to add:

  // Under "dependencies":
    "@microsoft/sp-core-library": "1.7.1",
    "@microsoft/sp-webpart-base": "1.7.1",
    "@microsoft/sp-lodash-subset": "1.7.1",
    "@microsoft/sp-office-ui-fabric-core": "1.7.1"

  // Under "devDependencies":
    "@microsoft/sp-build-web": "1.7.1",
    "@microsoft/sp-tslint-rules": "1.7.1",
    "@microsoft/sp-module-interfaces": "1.7.1",
    "@microsoft/sp-webpart-workbench": "1.7.1"

Now run npm install and your packages are with right versions required. Run gulp serve command after this, and it should open browser running the localhost workbench.

Case 2: Run the yeoman generator again and add a webpart or extension your project, this will automatically add the missing @microsoft/** packages to package.json file.

In case you receive and error regarding NodeJS version, follow this URL to solve the issue.

  • Thanks for the detailed answer, worked for me :) – JoseCarlosPB May 9 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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