microsoft-authentication-library-for-js icon indicating copy to clipboard operation
microsoft-authentication-library-for-js copied to clipboard

Azure function TSC build errors in msal-node

Open pragmatta opened this issue 9 months ago • 4 comments

Core Library

MSAL Node (@azure/msal-node)

Core Library Version

3.2.3

Wrapper Library

Not Applicable

Wrapper Library Version

Public or Confidential Client?

Public

Description

After updating my Azure function packages, started getting TSC build errors. First noticed this on function I had changed but getting same error on different function that was not changed. Looks like a regression in JS build.

Error Message

> tsc

node_modules/@azure/msal-common/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

1 /// <reference types="node" resolution-mode="require"/>
                        ~~~~

node_modules/@azure/msal-common/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts:2:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

2 /// <reference types="node" resolution-mode="require"/>
                        ~~~~

node_modules/@azure/msal-node/dist/config/Configuration.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

1 /// <reference types="node" resolution-mode="require"/>
                        ~~~~

node_modules/@azure/msal-node/dist/config/Configuration.d.ts:2:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

2 /// <reference types="node" resolution-mode="require"/>
                        ~~~~

node_modules/@azure/msal-node/dist/config/Configuration.d.ts:4:8 - error TS1192: Module '"http"' has no default export.

4 import http from "http";
         ~~~~

node_modules/@azure/msal-node/dist/config/Configuration.d.ts:5:8 - error TS1192: Module '"https"' has no default export.

5 import https from "https";
         ~~~~~

node_modules/@azure/msal-node/dist/request/InteractiveRequest.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

1 /// <reference types="node" resolution-mode="require"/>
                        ~~~~

node_modules/@azure/msal-node/dist/request/InteractiveRequest.d.ts:2:23 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

2 /// <reference types="node" resolution-mode="require"/>
                        ~~~~


Found 8 errors in 3 files.

Errors  Files
     2  node_modules/@azure/msal-common/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts:1
     4  node_modules/@azure/msal-node/dist/config/Configuration.d.ts:1
     2  node_modules/@azure/msal-node/dist/request/InteractiveRequest.d.ts:1

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • [ ] Sent
  • [ ] Pending

MSAL Configuration

I'm not directly using MSAL but following azure packages

    "@azure/functions": "^4.0.0",
    "@azure/core-http": "^3.0.0",
    "@azure/keyvault-secrets": "^4.0.0",
    "@azure/storage-queue": "^12.25.0",
    "@azure/communication-email": "^1.0.0",

Relevant Code Snippets

N/A

Reproduction Steps

N/A

Expected Behavior

TSC should complete without errors.

Identity Provider

Other

Browsers Affected (Select all that apply)

None (Server)

Regression

No response

pragmatta avatar Feb 25 '25 20:02 pragmatta

I can confirm that adding @azure/identity reference to package.json and downgrading version from 4.7.0 to 4.6.0 resolves the issue.

pragmatta avatar Mar 09 '25 09:03 pragmatta

@pragmatta Identity package takes a dependency on msal-node. The build errors you see are coming from msal-node. If you downgrade version of identity package, you are also downgrading msal-node version to v2

KarishmaGhiya avatar Mar 26 '25 21:03 KarishmaGhiya

Two things I needed to do:

First enable esModuleInterop in tsconfig.json. This will also enable allowSyntheticDefaultImports.

After this, ensure that your typescript dev dependency in your package.json is up to date. I am using 5.8.3 as we speak. Doesn't hurt to upgrade your global typescript either npm install -g typescript.

No need to downgrade anything.

codepic avatar Apr 07 '25 17:04 codepic

This is still an issue with the current repo.

I made the above changes suggested by codepic in the ElectronTestApp folder and it worked. Specifically, typescript 5.2.2 in package.json devDependencies and esModuleInterop: true in tsconfig.json.

EDIT: Here are my package versions that worked - "devDependencies": { "babel": "^6.23.0", "electron": "^33.2.1", "typescript": "^5.2.2" }, "dependencies": { "@azure/msal-node": "^3.8.0", "axios": "^1.9.0" }

ScottBlanck-Hxgn avatar Oct 10 '25 21:10 ScottBlanck-Hxgn