pnp / sp-dev-fx-webparts

SharePoint Framework web part, Teams tab, personal app, app page samples
http://aka.ms/spfx-webparts
MIT License
2.03k stars 3.83k forks source link

react-script-editor-onprem #3705

Closed Gennady-G closed 1 year ago

Gennady-G commented 1 year ago

Disclaimer

Yes

Sample

react-script-editor-onprem

Contributor(s)

@wobba

Question

Greetings Mikael!

Don't You have compiled version of react-script-editor-onprem (react-script-editor-onprem.sppkg)?

I successfully created SPO version, but give tons of errors trying to build parallel stack for SharePoint 2019 (I tried to use NVM to install node/gulp/yoeman/etc as described here but no luck.) Can You please share package for SP2019?

Best regards, Gennady

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

wobba commented 1 year ago

Sorry I don't. Guess it's a matter of getting the right SPFx + node working.

Gennady-G commented 1 year ago

Thank You Mikael!

Yes, imho the problem is to have both versions for O365 and 2019.. I'll try to use virtual machine or my notebook to install 2019 Dev environment from scratch..

Best regards, Gennady

wobba commented 1 year ago

You can try to update the parts to SPFx v1.10 as well which works for 2019.

Gennady-G commented 1 year ago

You can try to update the parts to SPFx v1.10 as well which works for 2019.

Thank You Mikael!

Gennady-G commented 1 year ago

Hi again @wobba!

Strange - I added new VM with Windows 11, installed Node.js v8.17.0 there, and other versions compatible with SP 2019:

npm install gulp-cli@2.3.0 yo@3.1.1 @microsoft/generator-sharepoint@1.10.0 --global

like described Andrew Connell here: https://www.voitanos.io/blog/definitive-guide-sharepoint-framework-sharepoint-server-2019/

Also fired "Set-ExecutionPolicy Unrestricted" in powershell ISE. But when I run "gulp serve" after 'npm install' - I get an error:

PS C:\prj\react-script-editor-onprem> gulp serve
C:\prj\react-script-editor-onprem\node_modules\@microsoft\spfx-heft-plugins\lib\plugins\devDeployPlugin\SpDevDeploy.js:165
            for await (const file of filesIterable) {
                ^^^^^

SyntaxError: Unexpected reserved word
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\prj\react-script-editor-onprem\node_modules\@microsoft\spfx-heft-plugins\lib\plugins\devDeployPlugin\DevDeployPlugin.js:28:23)
PS C:\prj\react-script-editor-onprem>

err-2-2023-05-25_200709

Maybe I do something wrong?

wobba commented 1 year ago

Some typescript issue. Your best option is to just create a new SPFx web part and put your code into it. Proper goverance as enabling script to anyone editing a page is a bad idea :)

Gennady-G commented 1 year ago

Also tried to install versions from 1.4.1 from here: https://learn.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-2019-and-subscription-edition-support

But also get error: gulp is not found at all

gulp-2023-05-25_213339

Maybe I need to use different command for old gulp-CLI?..

--

enabling script to anyone editing a page is a bad idea :)

Yes You are right.. But Your webpart could be fantastically useful for small fixes and something like "modern masterpages" - Yes they do not exist but sometimes it is cool to have something like few responsive links on homepage, etc.

So I can quickly make html/js/css markup and drop it to page. It is very long process to make a new webpart for every link fix/change

markup-2023-05-25_203902

wobba commented 1 year ago

If I have time I'll try to build it or upgrade to SP2019.

Gennady-G commented 1 year ago

Thank You Mikael! I'll keep You posted if I had luck with this build

Gennady-G commented 1 year ago

Thank You @wobba! I ended up recreating new webpart from generator for SPFx1.10, and migrated Your code there. Thank You again for these webparts! 👍

AdamantiumWolverine commented 1 month ago

Hi again @wobba!

Strange - I added new VM with Windows 11, installed Node.js v8.17.0 there, and other versions compatible with SP 2019:

npm install gulp-cli@2.3.0 yo@3.1.1 @microsoft/generator-sharepoint@1.10.0 --global

like described Andrew Connell here: https://www.voitanos.io/blog/definitive-guide-sharepoint-framework-sharepoint-server-2019/

Also fired "Set-ExecutionPolicy Unrestricted" in powershell ISE. But when I run "gulp serve" after 'npm install' - I get an error:

PS C:\prj\react-script-editor-onprem> gulp serve
C:\prj\react-script-editor-onprem\node_modules\@microsoft\spfx-heft-plugins\lib\plugins\devDeployPlugin\SpDevDeploy.js:165
            for await (const file of filesIterable) {
                ^^^^^

SyntaxError: Unexpected reserved word
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\prj\react-script-editor-onprem\node_modules\@microsoft\spfx-heft-plugins\lib\plugins\devDeployPlugin\DevDeployPlugin.js:28:23)
PS C:\prj\react-script-editor-onprem>

err-2-2023-05-25_200709

Maybe I do something wrong?

I had the same error after running "npm install" and it added a bunch of node_modules to the project.

The error is because gulp 2.3.0 doesn't understand the asynchronous command syntax used in the @microsoft\spfx-heft-plugins. I wound up doing something similar to what you did.

1) Create a new SharePoint web part based on the yo generator for SharePoint using the versions specified in the definitive guide to SPFX environment. https://www.voitanos.io/blog/definitive-guide-sharepoint-framework-sharepoint-server-subscription-edition/

I selected react as the framework.

2) I, then, replaced the gulpfile.js, package.config, package-lock.config file with the one from the new default web part project and node_modules folder with the one from the new default web part project.

This ensured that only the necessary, spFX 1.4.1 compatible modules were added to the project.

3) Then, I ran gulp serve and was able to test the script editor web part on the workbench.