Skip to content

Conversation

yulei-chen
Copy link

@yulei-chen yulei-chen commented Mar 20, 2024

Pull Request

Purpose

This PR adds a npm run build script to postinstall script in /1-Authentication/1-Sign-in/App/package.json, to solve the following problem when running npm start

image

❯ npm start

> [email protected] start
> node server.js

node:internal/modules/cjs/loader:446
      throw err;
      ^

Error: Cannot find module 'C:\Users\Yulei_Chen\github\ms-identity-javascript-nodejs-tutorial\1-Authentication\1-sign-in\App\node_modules\msal-node-wrapper\dist\index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:438:19)
    at Module._findPath (node:internal/modules/cjs/loader:680:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (C:\Users\Yulei_Chen\github\ms-identity-javascript-nodejs-tutorial\1-Authentication\1-sign-in\App\app.js:9:32)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\Users\\Yulei_Chen\\github\\ms-identity-javascript-nodejs-tutorial\\1-Authentication\\1-sign-in\\App\\node_modules\\msal-node-wrapper\\package.json',   
  requestPath: 'msal-node-wrapper'
}

Node.js v18.17.1

This bug is because it's the first time I run npm start in any chapter, the helper inside /Common hasn't been built before.
Actually, we need to add npm run build to every postinstall in case of the above bug, but this PR just adds for /1-Authentication/1-sign-in/.

Does this introduce a breaking change

    [ ] Yes
    [x] No

Pull request type

What kind of change does this Pull Request introduce?

    [x] Bugfix
    [ ] Feature
    [ ] Code style update (formatting, local variables)
    [ ] Documentation content changes
    [ ] Other... Please describe:

How to test

  • Get the code
    git clone https://github.com/yuleicul/ms-identity-javascript-nodejs-tutorial.git
    cd ms-identity-javascript-nodejs-tutorial
    git checkout yulei-patch-1
    cd 1-Authentication/1-sign-in/App
    npm install
    npm start

What to check

ex: verify that the following are valid:

  • The server can be started successfully after running npm start

Other Information

Related issue: Please Fix the following issue I was having when running npm start in sample \4-AccessControl\2-security-groups · Issue #100 · Azure-Samples/ms-identity-javascript-nodejs-tutorial

@SimonHylander
Copy link

This solved the problem for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants