Skip to content

msal-browser error: Module not found: Can't resolve '@azure/msal-common' in...\..\node_modules\@azure\msal-browser\dist' #6904

Open
@dianahamzea

Description

@dianahamzea

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.9.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.0.11

Public or Confidential Client?

Public

Description

Hello, I am trying to switch from ADAL authentication to MSAL authenticationI am using React JS. The issue is that the only version of @azure/msal-browser is 2.38.3 which is deprecated. I want to use newer version but I ran into this error
./node_modules/@azure/msal-browser/dist/index.mjs

Module not found: Can't resolve '@azure/msal-common' in '...\node_modules@azure\msal-browser\dist'

I tried different versions of msal-browser abve 3.0.0 which are not deprecated, but I have same result.

I also tried to install @azure/msal-common with a matching version with msal-browser based on the dependecies in package-lock.json.

Currently I have this setup in packaje.json

"@azure/msal-browser": "^3.9.0",

"@azure/msal-common": "^14.7.0",

"@azure/msal-react": "^2.0.11",

"react": "^16.14.0",

I use node 14.19.0

I saw same issue at #6714 , but it's closed with no working solutions

Error Message

./node_modules/@azure/msal-browser/dist/index.mjs

Module not found: Can't resolve '@azure/msal-common' in '...\node_modules@azure\msal-browser\dist'

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

msalConfig = {
            auth: {
                clientId: clientID,
                authority:authority,
                redirectUri: window.location.origin + "/loginResult",
            },
            cache: {
                cacheLocation: 'sessionStorage',
            },

Relevant Code Snippets

import { PublicClientApplication} from "@azure/msal-browser";

class App extends Component {
    constructor(props) {
        super(props);

        this.state = {
            isAuthenticated: false,
            accessToken: null,
        };

         this.msalConfig = {
            auth: {
                clientId: clientID,
                authority:authority
                redirectUri: window.location.origin + "/loginResult", 
            },
            cache: {
                cacheLocation: 'sessionStorage', 
            },
        };

        this.pca = new PublicClientApplication(this.msalConfig);
    }
//as soon as PublicClientApplication is imported I get this error

Reproduction Steps

  1. npm install @azure/msal-react @azure/msal-browser @azure/msal-common
  2. import { PublicClientApplication} from "@azure/msal-browser";
  3. error is displayed after npm start

Expected Behavior

should not get an error

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

Chrome, Edge

Regression

@azure/msal-browser 2.38.3

Source

External (Customer)

Metadata

Metadata

Assignees

Labels

bugA problem that needs to be fixed for the feature to function as intended.msal-angularRelated to @azure/msal-angular packagemsal-browserRelated to msal-browser packagepublic-clientIssues regarding PublicClientApplications

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions