Loading external library fails “If loading a global module configure the global name via…”
-
08-12-2020 - |
Pergunta
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";
andWinston.info("LOG TEST");
Using Windows 10, generator v0.1.2, chrome browser
Solução
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?