I put the same question on stackoverflow
This problem is killing me. Please help. I have following file structure:
protractor
typescript
package.json
register-popup.ts
The content of package.json
{
"name": "typescriptProba",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"protractor": "^4.0.11",
"typescript": "^2.0.10"
}
}
The content of register-popup.ts:
import { ElementFinder, element, by } from "protractor";
export class RegisterPopup {
public registerWithFacebookButton: ElementFinder = element(by.css('li.facebook a'));
public registerWithGoogleButton: ElementFinder = element(by.css('li.google a'));
public registerWithEmailButton: ElementFinder = element(by.css('li.email a'));
public registerWithMobileButton: ElementFinder = element(by.css('li.natel a'));
constructor () {}
openPopup() {
element(by.css('.account.user')).click();
element(by.id('openRegister')).click();
}
openRegisterByEmailPopup() {
this.registerWithEmailButton.click();
}
openRegisterByPhonePopup() {
this.registerWithMobileButton.click();
}
}
For compiling ts file to js file I am using following command:
./node_modules/typescript/bin/tsc "./register-popup.ts" --module commonjs --noResolve --traceResolution
After executing command I have following error:
error TS2307: Cannot find module 'protractor'.
But my module trace resolution is like this:
======== Resolving module 'protractor' from '/Users/predraglazarevic/www/typescriptProba/register-popup.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'protractor' from 'node_modules' folder.
File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor.ts' does not exist.
File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor.tsx' does not exist.
File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor.d.ts' does not exist.
Found 'package.json' at '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/package.json'.
'package.json' has 'typings' field 'built/index.d.ts' that references '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts'.
File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts' exist - use it as a name resolution result.
Resolving real path for '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts', result '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts'
======== Module name 'protractor' was successfully resolved to '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts'. ========
So I have
Module name 'protractor' was successfully resolved
but still have error
error TS2307: Cannot find module 'protractor'.
Why?
Why did you close this? Did you find a resolution? If so, could you share your findings?
I put the same question on stackoverflow
This problem is killing me. Please help. I have following file structure:
protractor typescript package.json register-popup.tsThe content of package.json
{ "name": "typescriptProba", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "protractor": "^4.0.11", "typescript": "^2.0.10" } }The content of register-popup.ts:
import { ElementFinder, element, by } from "protractor"; export class RegisterPopup { public registerWithFacebookButton: ElementFinder = element(by.css('li.facebook a')); public registerWithGoogleButton: ElementFinder = element(by.css('li.google a')); public registerWithEmailButton: ElementFinder = element(by.css('li.email a')); public registerWithMobileButton: ElementFinder = element(by.css('li.natel a')); constructor () {} openPopup() { element(by.css('.account.user')).click(); element(by.id('openRegister')).click(); } openRegisterByEmailPopup() { this.registerWithEmailButton.click(); } openRegisterByPhonePopup() { this.registerWithMobileButton.click(); } }For compiling ts file to js file I am using following command:
./node_modules/typescript/bin/tsc "./register-popup.ts" --module commonjs --noResolve --traceResolution
After executing command I have following error:
error TS2307: Cannot find module 'protractor'.
But my module trace resolution is like this:
======== Resolving module 'protractor' from '/Users/predraglazarevic/www/typescriptProba/register-popup.ts'. ======== Module resolution kind is not specified, using 'NodeJs'. Loading module 'protractor' from 'node_modules' folder. File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor.ts' does not exist. File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor.tsx' does not exist. File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor.d.ts' does not exist. Found 'package.json' at '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/package.json'. 'package.json' has 'typings' field 'built/index.d.ts' that references '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts'. File '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts' exist - use it as a name resolution result. Resolving real path for '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts', result '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts' ======== Module name 'protractor' was successfully resolved to '/Users/predraglazarevic/www/typescriptProba/node_modules/protractor/built/index.d.ts'. ========So I have
Module name 'protractor' was successfully resolved
but still have errorerror TS2307: Cannot find module 'protractor'.
Why?
Managed to resolve it?
I cannot remember why I closed the issue. It was a long time ago. I know for sure that I didn't find solution
I cannot remember why I closed the issue. It was a long time ago. I know for sure that I didn't find solution
Okay, hvala.
Most helpful comment
Why did you close this? Did you find a resolution? If so, could you share your findings?