I have created a service in file 'myapi.service.ts' which contains:
export class MyAPIService {
and in my component I import the service as follows:
import { MyAPIService } from '../myapi.service';
But everytime I compile I get this error:
Module '"/myapi.service"' has no exported member 'MyAPIService'.
The problem seems to be capitalizatio.n If I import "MyapiService" instead of "MyAPIService" then it compiles fine. But why? Does ng2 require/force certain capitalization? Shouldn't it use the capitalization I used when creating the class?
There is no such a thing in Angular or TypeScript. Make sure there is no other mistake somewhere in your code.
Here's a working example
Maybe also (although this is a real edge case), check your webpack config if there's anything going super crazy in there, or you played with the
paths
property of tsconfig, but most likely it's a much simpler mistake in your code.Maybe you needed to restart your build watch / dev server too or so as well.
Update
If this is an external dependency (NPM module), then try removing your
node_modules
folder and runningnpm install
again.As in comments, this was the case for the OP.