Ссылки на изображения в веб-части SharePoint Framework - PullRequest
0 голосов
/ 02 мая 2018

Я пытаюсь создать простую веб-часть SharePoint Online, содержащую изображение. Проблема в том, что изображение, упакованное в WebPart, не отображается.

Я нашел это решение: https://mattjimison.com/2017/06/03/referencing-images-sharepoint-framework-webpart/

Но проблема в том, что я получаю сообщение об ошибке gulp serve:

[10:19:10] Finished subtask 'post-copy' after 4.25 ms
[10:19:10] Starting subtask 'collectLocalizedResources'...
  Request: '/node_modules/@microsoft/sp-page-context/dist/sp-page-context.js'
[10:19:10] Finished subtask 'collectLocalizedResources' after 26 ms
[10:19:10] Starting subtask 'configure-webpack'...
[10:19:11] Finished subtask 'configure-webpack' after 561 ms
[10:19:11] Starting subtask 'webpack'...
  Request: '/node_modules/@microsoft/sp-component-base/dist/sp-component-base.js'
  Request: '/node_modules/@microsoft/sp-extension-base/dist/sp-extension-base_en-us.js'
  Request: '/node_modules/@microsoft/sp-application-base/dist/sp-application-base_en-us.js'
  Request: '/node_modules/react/dist/react.js'
  Request: '/node_modules/react-dom/dist/react-dom.js'
[10:19:11] Error - [webpack] 'dist':
./lib/webparts/socialLinks/SocialLinksWebPart.js
Module not found: Error: Can't resolve 'set-webpack-public-path' in 'c:\runemy\git\spfx-social-links\lib\webparts\socialLinks'
resolve 'set-webpack-public-path' in 'c:\runemy\git\spfx-social-links\lib\webparts\socialLinks'
  Parsed request is a module
  using description file: c:\runemy\git\spfx-social-links\package.json (relative path: ./lib/webparts/socialLinks)
  after using description file: c:\runemy\git\spfx-social-links\package.json (relative path: ./lib/webparts/socialLinks)
    resolve as module
      c:\runemy\git\spfx-social-links\lib\webparts\socialLinks\node_modules doesn't exist or is not a directory
      c:\runemy\git\spfx-social-links\lib\webparts\node_modules doesn't exist or is not a directory
      c:\runemy\git\spfx-social-links\lib\node_modules doesn't exist or is not a directory
      c:\runemy\git\node_modules doesn't exist or is not a directory
      c:\runemy\node_modules doesn't exist or is not a directory
      looking for modules in c:\runemy\git\spfx-social-links\node_modules
        using description file: c:\runemy\git\spfx-social-links\package.json (relative path: ./node_modules)

Похоже, это отсутствующий модуль? Как я могу получить это и запустить?

1 Ответ

0 голосов
/ 02 мая 2018

Дело закрыто

Дело решается с помощью:

npm install @microsoft/loader-set-webpack-public-path
npm install @microsoft/set-webpack-public-path-plugin --save-dev

И замена require('set-webpack-public-path!') на require("@microsoft/loader-set-webpack-public-path!");

-Rune

...