Gojs Error in Typescript SPFX

Iam using SPFX webpart development. Iam getting the below error while importing gojs as below
import * as go from ‘gojs/release/go-module’;

typescript version : 4.1.3
Gojs : 2.1.33

Iam getting the below error while running the application

  • node_modules\gojs\release\go-module.d.ts(11913,4): error TS7028: Unused label.

I just upgraded my version of TSC from 3.9.7 to 4.1.3. I then recompiled all of the TypeScript code in ./extensionsJSM, which all do:

import * as go from '../release/go-module.js';

You can do it by just executing “tsc” in that directory.

There were no errors or warnings. So, could you please tell us how to reproduce that error?

this is sharepoint development. Please find the below steps to reproduce
1.Create a folder in your local.
2.Run yo @microsoft/sharepoint in your command prompt frpm the folder
3. Give appropriate names and select 2016 onwards including sharepoint online and select React Option.
4.A solution will be created .
5. Run npm install gojs @latest
6.Inside the component folder there will be tsx file inside the solution. there give import * as go from ‘gojs/release/go-module.js’; and run gulp serve .

I had to first do:
npm i -g yo
npm install @microsoft/generator-sharepoint
yo @microsoft/sharepoint
npm i -g gulp
before the rest of your instructions could work.

I get a ReferenceError: primordials is not defined error.
That doesn’t involve GoJS at all, and that’s not the error that you are getting.

FYI, npm also provides this information:

found 1049 vulnerabilities (483 low, 28 moderate, 533 high, 5 critical)
  run `npm audit fix` to fix them, or `npm audit` for details

So I was unable to reproduce the problem.

install node js in your system
and then follow the below commands in that order

npm install -g yo gulp

npm install -g @microsoft/generator-sharepoint

yo @microsoft/sharepoint

Please follow the below doc if you have doubts

you have to install gulp at the begining

Iam stuck in this issue for a long time .it would be a great help if this is resolved.

Those are the commands I executed, twice, in a new directory each time.
I will try it again, but I don’t know how or why the result would be different.

yes please try and let me know

For reference:

$ node -v
v14.7.0
$ npm -v
6.14.7
$ tsc -v
Version 4.1.3

Here’s what I did:

$ cd /temp
$ mkdir spfx
$ cd spfx
$ npm i -g yo gulp
$ npm i -g @microsoft/generator-sharepoint
$ yo @microsoft/sharepoint

And I chose SharePoint 2016 onwards and React,

$ npm i gojs

Then I edited spfx/src/webparts/helloWorld/components/HelloWorld.tsx to add this line:

import * as go from 'gojs/release/go-module.js';

Finally:

$ gulp serve
ReferenceError: primordials is not defined
    at fs.js:40:5

One difference from before is that this time I installed @microsoft/generator-sharepoint globally. But the results were the same.

please downgrade version to 8 or 9 .
and then run gulp trust-dev-cert
run SET NODE_NO_HTTP2=1
before gulp serve

downgrade the nodejs version to 8 or 9

My version

Node : v8.9.4
Npm : 6.14.8
gulp -v
CLI version: 2.3.0
Local version: 3.9.1

tsc -v
Version 4.1.3

Sorry, but Node.js version 8 is no longer supported, so I’m not going to downgrade.
Even version 10 is about to go to end-of-life. https://nodejs.org/en/about/releases/

suspect you’re using node 14 and gulp 3. That combination does not work: https://github.com/gulpjs/gulp/issues/2324

A previous workaround from Jan. does not work either: https://github.com/gulpjs/gulp/issues/2246

Solution: Either upgrade to gulp 4 or downgrade to an earlier node.

This is the error iam gettimg while importing gojs

Please refere this if any of that didnt work

Those error messages don’t make any sense at all. The go.d.ts file is generated by the TypeScript compiler when compiling the GoJS source code. We never see that kind of error in our use of it, and no one else has reported anything like it.

The “How to fix …” link would be useful for someone who knew where the problem was occurring, but I have no idea about that. I don’t understand why getting the latest version of software from npm would result in a broken process – I think waiting until the responsible people fix it correctly is my only practical choice for now.

this error was not occuring when Iam using lower version of typescript

Could you please show the TypeScript code that is being compiled that is causing the problem? Along with how you are invoking the compiler (tsc)?

I want to be able to reproduce the problem. Involving all kinds of other tools shouldn’t be necessary for reproducing a simple compilation bug.