1

I'm trying to load winston into the default React (hello world) component, but I cannot get it to work. When running in workbench and adding the webpart I receive the following error:

Error: Unable to load web part script resources due to: Error: Error: https://spoppe-a.akamaihd.net/files/winston did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support. Error loading https://spoppe-a.akamaihd.net/files/winston. at https://dci5cg6011dzr:4321/node_modules/@microsoft/sp-client-preview/dist/sp-client-preview.js:17250:32

The winston.js file is loaded correctly, as I can see in the browser's network tab, but indeed the address "https://spoppe-a.akamaihd.net/files/winston" is unreachable/invalid.

To reproduce, I performed the following:

  • npm install --save winston
  • tsd install winston --save
  • added the winston library as external reference in config/config.json
  • in code: import * as Winston from "winston"; and Winston.info("LOG TEST");

Using Windows 10, generator v0.1.2, chrome browser

1

The error states that it is looking for winston off of the Microsoft hosted akamai servers (https://spoppe-a.akamaihd.net/files/winston), which is probably not where it is. What does your external reference look like? Does it have a fully qualified path to where the code is hosted?

  • There is no reference at all to the MS servers. The external reference points to /node_modules/winston/lib/winston.js, which is loaded correctly (visible in the network profiler). I just have no idea where the reference to the MS servers comes from. Perhaps this is a bug? – Nsevens Sep 21 '16 at 8:25
  • So you can't reference an entry in node_modules as external. External means "this is coming from someplace external to my bundle / code". By not having a fully qualified external URL, it will be treated as relative, and will look on the same server that the framework is coming from. You either need to bundle it internally, or find an external server where it is hosted (and use that full URL). Does that make sense? – PatMill_MSFT Sep 21 '16 at 16:53
  • Hi @PatMill_MSFT. This makes sense indeed. However, what's the difference then with React module? (Thank you for your reply on github as well) – Nsevens Sep 21 '16 at 20:41
  • Sorry, my mistake. I misspoke earlier. What you are trying to do is possible, just not with winston. You followed the directions on the external library page (dev.office.com/sharepoint/docs/spfx/web-parts/basics/…) correctly. The issue here is that a) our error reporting in the module loader needs some work and b) winston isn't set up to be included as an AMD module in a browser based experience, rather it is to be included into a node.js server app. I've updated the github issue around this (github.com/SharePoint/sp-dev-docs/issues/207). – PatMill_MSFT Sep 22 '16 at 0:20
  • All right. Thank you @PatMill_MSFT. So as I understand, the issue is not with the code/config I used, but more that the library is not supported in a browser based solution? – Nsevens Sep 22 '16 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.