Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Can't resolve '@ms/sp-telemetry' when using SPHttpClient or GraphHttpClient #1076

Closed
NickSevens opened this issue Nov 23, 2017 · 2 comments

Comments

@NickSevens
Copy link

commented Nov 23, 2017

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

When using SPHttpClient or GraphHttpClient, I expect gulp bundle to succeed.

Observed Behavior

When adding the following example code, the bundle task fails with the error below:
new SPHttpClient(this.context.serviceScope).fetch("<url>", SPHttpClient.configurations.v1, {});

Error - [webpack] 'dist':
./node_modules/@microsoft/sp-http/lib/spHttpClient/SPHttpClient.js
Module not found: Error: Can't resolve '@ms/sp-telemetry' in 'C:/Projects/_Testing/spfx-test-solution/node_modules/@microsoft/sp-http/lib/spHttpClient'
resolve '@ms/sp-telemetry' in 'C:/Projects/_Testing/spfx-test-solution/node_modules/@microsoft/sp-http/lib/spHttpClient'

I tried (re-)installing the latest version of the generator (1.3.4), but this didn't help.

Also, calling GraphHttpClient instead of SPHttpClient gave me some more errors coming from @ms modules.

Steps to Reproduce

  • (Install SPFx generator npm i -g @microsoft/generator-sharepoint)
  • Create a new SPFx project yo @microsoft/sharepoint
  • Follow the wizard to create a new webpart (tested with both React and "no framework" - both gave the same result)
  • Add a call to SPHttpClient or GraphHttpClient to the code: new SPHttpClient(this.context.serviceScope).fetch("<url>", SPHttpClient.configurations.v1, {});
  • Run gulp bundle

@NickSevens NickSevens changed the title Webpack task failing in new SPFx project: Module not found: Error: Can't resolve '@ms/sp-telemetry' Module not found: Error: Can't resolve '@ms/sp-telemetry' when using SPHttpClient or GraphHttpClient Nov 23, 2017

@NickSevens NickSevens closed this Nov 23, 2017

@ab14jain

This comment has been minimized.

Copy link

commented Jan 3, 2018

Even i got the same error.

The correct usage is

import { SPHttpClient } from '@microsoft/sp-http';

this.context.spHttpClient.get('/_api/web', SPHttpClient.configurations.v1);

@piero-b

This comment has been minimized.

Copy link

commented Apr 26, 2018

I have added a UserVoice to prioritise getting this fixed. Please up-vote it if you are interested as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.