pnp / sp-starter-kit

Modern SharePoint Starter Kit - End-to-end showcase solution to get started with modern experiences.
MIT License
761 stars 535 forks source link

'Cannot find module '@starter-kit/shared-library'.' error when building react-personal-calendar #457

Closed waldekmastykarz closed 3 years ago

waldekmastykarz commented 3 years ago

Category

Describe the bug

Expected or Desired Behavior

Run gulp serve without any issues

Observed Behavior

When running gulp serve, you get the following error:

Cannot find module '@starter-kit/shared-library'.

Steps to Reproduce

FWIW, I followed the steps from https://github.com/pnp/sp-starter-kit/issues/427. After manually adding @starter-kit/shared-library to dependencies, I'm getting the following error:

[16:09:25] Error - [webpack] 'dist':
../library-starter-kit-shared/lib/libraries/spStarterKitShared/SpStarterKitSharedLibrary.js
Module not found: Error: Can't resolve 'SpStarterKitSharedLibraryStrings' in '/usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/spStarterKitShared'
resolve 'SpStarterKitSharedLibraryStrings' in '/usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/spStarterKitShared'
  Parsed request is a module
  using description file: /usr/sp-starter-kit/source/library-starter-kit-shared/package.json (relative path: ./lib/libraries/spStarterKitShared)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/spStarterKitShared/node_modules doesn't exist or is not a directory
      /usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/spStarterKitShared/lib doesn't exist or is not a directory
      /usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/node_modules doesn't exist or is not a directory
      /usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/lib doesn't exist or is not a directory
      /usr/sp-starter-kit/source/library-starter-kit-shared/lib/node_modules doesn't exist or is not a directory
      /usr/sp-starter-kit/source/library-starter-kit-shared/lib/lib doesn't exist or is not a directory
      /usr/sp-starter-kit/source/node_modules doesn't exist or is not a directory
      /usr/sp-starter-kit/source/lib doesn't exist or is not a directory
      /usr/sp-starter-kit/node_modules doesn't exist or is not a directory
      /usr/sp-starter-kit/lib doesn't exist or is not a directory
      /usr/node_modules doesn't exist or is not a directory
      /usr/lib doesn't exist or is not a directory
      /Users/waldek/github/node_modules doesn't exist or is not a directory
      /Users/waldek/github/lib doesn't exist or is not a directory
      /Users/waldek/node_modules doesn't exist or is not a directory
      /Users/waldek/lib doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /Users/lib doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      /lib doesn't exist or is not a directory
      looking for modules in /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules
        using description file: /usr/sp-starter-kit/source/library-starter-kit-shared/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /usr/sp-starter-kit/source/library-starter-kit-shared/lib
        using description file: /usr/sp-starter-kit/source/library-starter-kit-shared/package.json (relative path: ./lib)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /usr/sp-starter-kit/source/library-starter-kit-shared/package.json (relative path: ./node_modules/SpStarterKitSharedLibraryStrings)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /usr/sp-starter-kit/source/library-starter-kit-shared/package.json (relative path: ./lib/SpStarterKitSharedLibraryStrings)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.json doesn't exist
              /usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.json doesn't exist
            as directory
              /usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings doesn't exist
            as directory
              /usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings doesn't exist
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/spStarterKitShared/node_modules]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/spStarterKitShared/lib]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/node_modules]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/libraries/lib]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/node_modules]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/lib]
[/usr/sp-starter-kit/source/node_modules]
[/usr/sp-starter-kit/source/lib]
[/usr/sp-starter-kit/node_modules]
[/usr/sp-starter-kit/lib]
[/usr/node_modules]
[/usr/lib]
[/Users/waldek/github/node_modules]
[/Users/waldek/github/lib]
[/Users/waldek/node_modules]
[/Users/waldek/lib]
[/Users/node_modules]
[/Users/lib]
[/node_modules]
[/lib]
[/usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings]
[/usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.wasm]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.wasm]
[/usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.mjs]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.mjs]
[/usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.js]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.js]
[/usr/sp-starter-kit/source/library-starter-kit-shared/node_modules/SpStarterKitSharedLibraryStrings.json]
[/usr/sp-starter-kit/source/library-starter-kit-shared/lib/SpStarterKitSharedLibraryStrings.json]
 @ ../library-starter-kit-shared/lib/libraries/spStarterKitShared/SpStarterKitSharedLibrary.js 1:0-60 13:19-26 16:19-26
 @ ../library-starter-kit-shared/lib/index.js
 @ ./lib/webparts/personalCalendar/PersonalCalendarWebPart.js
ghost commented 3 years ago

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

waldekmastykarz commented 3 years ago

OK, seems you can fix the issue by running gulp bundle in the library, rather than just gulp build. It would be helpful to write these steps down in the readme to avoid others from running into the same issues when trying to build the project locally.

eoverfield commented 3 years ago

Thanks for finding this. This is strange, bundling shouldn't be needed during a local build as when the build process creates the lib folder, I would expect that to be enough.

We are definitely short on documentation of both the library and the webparts that use it. i.e. https://github.com/pnp/sp-starter-kit/tree/master/source/library-starter-kit-shared. I will look to bump this up the task list.

eoverfield commented 3 years ago

Building / bundling / packaging documentation for this webpart has been updated to reflect how best to utilize the library component. https://github.com/pnp/sp-starter-kit/tree/master/source/react-personal-calendar.