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

Cannot read property 'join' of undefined path.posix #85

Closed
leblancdavid opened this issue Feb 2, 2018 · 11 comments
Closed

Cannot read property 'join' of undefined path.posix #85

leblancdavid opened this issue Feb 2, 2018 · 11 comments
Assignees

Comments

@leblancdavid
Copy link

I am getting an error when trying to login: (in microsoft-account.ts @116)

export async function getLiveKeys(options: LoadLiveKeysOptions): Promise<LiveKeys> { try { const uri: string = url.resolve(skypeLoginUri, path.posix.join("oauth", "microsoft"));

For some reason path.posix is undefined. I have the latest version of node.js. Any ideas why this would be the case?

@demurgos
Copy link
Member

demurgos commented Feb 2, 2018

@leblancdavid
Are you using the example in the repository or importing the library as a dependency?
If you are importing the lib as a dependency, are you using a transpiler or not? Do you use @std/esm?
What is your operating system?

It may be related to ESM imports. The package exposes both Commonjs and ESM modules.

@leblancdavid
Copy link
Author

leblancdavid commented Feb 2, 2018

To give you a bit more context, I'm trying to build an angular UI on top of it. I'm on windows 10. I'm trying to look at the example right now to figure out what I am missing. Here is my package.json

{
  "name": "epyks",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "latest",
    "@angular/cdk": "latest",
    "@angular/common": "latest",
    "@angular/compiler": "latest",
    "@angular/core": "latest",
    "@angular/forms": "latest",
    "@angular/http": "latest",
    "@angular/material": "latest",
    "@angular/platform-browser": "latest",
    "@angular/platform-browser-dynamic": "latest",
    "@angular/router": "latest",
    "core-js": "^2.4.1",
    "require.js": "^1.0.0",
    "rxjs": "latest",
    "zone.js": "^0.8.4",
    "skype-http": "latest"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.7",
    "@angular/compiler-cli": "latest",
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "^9.4.0",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "^4.0.0",
    "tslint": "~5.3.2",
    "typescript": "latest"
  }
}

Could it be related to my tsconfig.json?

@demurgos
Copy link
Member

demurgos commented Feb 2, 2018

Thanks: that's a good idea. I had a UI two years ago but did not have enough time to maintain it. I now focus on the lower-level library.

If you use Typescript, make sure that esModuleInterop and allowSyntheticDefaultImports are enabled. These are recent options required for compatibility with Node's ES modules. Your issue comes probably from the fact that your project is trying to recompile the files in the package. I'll have to check how to prevent it (or remove the TS sources, but it may hurt debugging with source maps).

In your tsconfig.json, set:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true
  }
}

Please also note that you can theoretically swap the IO layer by your own implementation if you set the io options to an object compatible with this interface. You will most likely have to proxy the the calls if you want to use the lib in the browser or have a server with an API on top of it (so the browser can access it). Browsers also have cross-domain protection so you won't be able to replace the IO with simple XHR but it may work in something like Electron (you may need to configure a few things).
The main issue with this interface is that it's still exposing request's cookies: I haven't really tried to swap the io in a long time, but I'd like to drop this explicit dependency on request to help with the kind of thing you're trying to do.

@demurgos
Copy link
Member

demurgos commented Feb 7, 2018

@leblancdavid
The original issue should be solved soon: I'm on it.

As mentioned previously, this is caused by the presence of the .ts files for source maps but TS prefers .ts over .d.ts so it picks the source files instead of the definitions when compiling your project. I'll move the source files to a different directory.

@leblancdavid
Copy link
Author

Great! I'll see if that helps. Part of me thinks that my dev environment is not configured correctly since I'm getting issues with the "esModuleInterop": true flag. In VS Code it recognizes it but when I "ng serve" it doesn't. But I can't seem to find why that is.

@demurgos
Copy link
Member

demurgos commented Feb 7, 2018

This option was introduced in Typescript 2.7, but I see that you are using latest in your package.json so it is a bit strange. Maybe try a clean reinstall (remove node_modules and lock files).

@demurgos demurgos self-assigned this Feb 7, 2018
@leblancdavid
Copy link
Author

Yes that was the issue. I was on typescript 2.6. Updating to 2.7 fixed that esModuleInterop issue but I still can't quite compile. Unfortunately I don't think the angular-cli is up to typescript 2.7 yet. I'm getting

ERROR in node_modules/kryo/readers/qs.ts(1,17): error TS7016: Could not find a declaration file for module 'qs'. 'F:/Projects/Epyks/node_modules/qs/lib/index.js' implicitly has an 'any' type.
Try npm install @types/qs if it exists or add a new declaration (.d.ts) file containing declare module 'qs';
node_modules/kryo/writers/qs.ts(1,17): error TS7016: Could not find a declaration file for module 'qs'. 'F:/Projects/Epyks/node_modules/qs/lib/index.js' implicitly has an 'any' type.
Try npm install @types/qs if it exists or add a new declaration (.d.ts) file containing declare module 'qs';
node_modules/skype-http/node_modules/kryo/types/document.ts(158,13): error TS2322: Type '{ [P in keyof T]: PropertyDescriptor<Type<T[P]>>; }[keyof T]' is not assignable to type 'PropertyDescriptor<T[keyof T]>'.
Type 'PropertyDescriptor<Type<T[keyof T]>>' is not assignable to type 'PropertyDescriptor<T[keyof T]>'.
Type 'Type<T[keyof T]>' is not assignable to type 'T[keyof T]'.
node_modules/skype-http/node_modules/kryo/types/document.ts(158,44): error TS2344: Type 'T[keyof T]' does not satisfy the constraint 'Type'.
node_modules/skype-http/node_modules/kryo/types/document.ts(163,59): error TS2345: Argument of type 'T[keyof T]' is not assignable to parameter of type 'Type<T[keyof T]>'.

This may simply be because of the angular-cli since I get this warning:

@angular/[email protected] requires typescript@'>=2.4.2 <2.7.0' but 2.7.1 was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.

Please run the following command to install a compatible version of TypeScript.

npm install typescript@'>=2.4.2 <2.7.0'

To disable this warning run "ng set warnings.typescriptMismatch=false".

@demurgos
Copy link
Member

demurgos commented Feb 7, 2018

Ok, thanks for the info.
I fixed the issue in the build tools, the next release should work fine with TS 2.6: it will probably be released today or tomorrow.

@demurgos
Copy link
Member

demurgos commented Feb 8, 2018

This issue is fixed by #87.
This ended up as a larger PR so I'll need to re-read it and clean-up some things before merging.

I also did a quick client for myself to test some features: it uses Angular for the frontend. I have custom services for contacts and conversations, but for events I just use a websocket to send them directly. WARNING: this is really messy (I use a single global instance of the Skype API, authentication is a bit brittle) but it may help you start a proper Angular client.
https://github.com/demurgos/ocilo
(Note: it relies on #87)

@demurgos
Copy link
Member

Closed by #89

@demurgos
Copy link
Member

The fix was published in version 0.0.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants