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

Running ng e2e throws cannot find definition files (rc0) #5082

Closed
adrianchia opened this issue Feb 27, 2017 · 8 comments · Fixed by #5251
Closed

Running ng e2e throws cannot find definition files (rc0) #5082

adrianchia opened this issue Feb 27, 2017 · 8 comments · Fixed by #5251

Comments

@adrianchia
Copy link

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
@angular/cli: 1.0.0-rc.0
node: 7.6.0
os: win32 x64
@angular/common: 4.0.0-rc.1
@angular/compiler: 4.0.0-rc.1
@angular/core: 4.0.0-rc.1
@angular/forms: 4.0.0-rc.1
@angular/http: 4.0.0-rc.1
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0-rc.1
@angular/platform-browser-dynamic: 4.0.0-rc.1
@angular/router: 4.0.0-rc.1
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 4.0.0-rc.1

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
The project was created via ng new -ng4 --routing --styles=scss hello

The log given by the failure.

Normally this include a stack trace and some more information.
webpack: Compiled successfully.
[16:06:50] I/update - chromedriver: file exists C:\Users\achia\workspace\hello\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.27.zip
[16:06:50] I/update - chromedriver: unzipping chromedriver_2.27.zip
[16:06:50] I/update - chromedriver: chromedriver_2.27.exe up to date
[16:06:50] I/launcher - Running 1 instances of WebDriver
[16:06:50] I/direct - Using ChromeDriver directly...
[16:06:53] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'jasmine'. (2688)
Cannot find type definition file for 'node'. (2688)
e2e\app.e2e-spec.ts (3,1): Cannot find name 'describe'. (2304)
e2e\app.e2e-spec.ts (6,3): Cannot find name 'beforeEach'. (2304)
e2e\app.e2e-spec.ts (10,3): Cannot find name 'it'. (2304)
e2e\app.e2e-spec.ts (12,5): Cannot find name 'expect'. (2304)
at getOutput (C:\Users\achia\workspace\hello\node_modules\ts-node\src\index.ts:312:17)
at C:\Users\achia\workspace\hello\node_modules\ts-node\src\index.ts:343:18
at Object.compile (C:\Users\achia\workspace\hello\node_modules\ts-node\src\index.ts:476:19)
at Module.m._compile (C:\Users\achia\workspace\hello\node_modules\ts-node\src\index.ts:406:44)
at Module._extensions..js (module.js:580:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\achia\workspace\hello\node_modules\ts-node\src\index.ts:409:12)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at C:\Users\achia\workspace\hello\node_modules\jasmine\lib\jasmine.js:87:5
at Array.forEach (native)
at Jasmine.loadSpecs (C:\Users\achia\workspace\hello\node_modules\jasmine\lib\jasmine.js:86:18)
at Jasmine.execute (C:\Users\achia\workspace\hello\node_modules\jasmine\lib\jasmine.js:181:8)
at C:\Users\achia\workspace\hello\node_modules\protractor\built\frameworks\jasmine.js:132:15
at Function.promise (C:\Users\achia\workspace\hello\node_modules\q\q.js:682:9)
at C:\Users\achia\workspace\hello\node_modules\protractor\built\frameworks\jasmine.js:104:14
at _fulfilled (C:\Users\achia\workspace\hello\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\achia\workspace\hello\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\achia\workspace\hello\node_modules\q\q.js:796:13)
at C:\Users\achia\workspace\hello\node_modules\q\q.js:556:49
at runSingle (C:\Users\achia\workspace\hello\node_modules\q\q.js:137:13)
at flush (C:\Users\achia\workspace\hello\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[16:06:53] E/launcher - Process exited with error code 100

Mention any other details that might be useful.

Setting types in e2e/tsconfig.e2e.json to typeRoot pointing to ../node_modules/@types seems resolve the problem.


Thanks! We'll be in touch soon.

@JohannesHoppe
Copy link
Contributor

I can confirm this! 😢

@JohannesHoppe
Copy link
Contributor

JohannesHoppe commented Feb 28, 2017

As @adrianchia already pointed out, this e2e/tsconfig.e2e.json fixes the issue temporarily:

{
 "extends": "../tsconfig.json",
 "compilerOptions": {
   "outDir": "../dist/out-tsc-e2e",
   "module": "commonjs",
   "target": "es6",
   "types":[
     "jasmine",
     "node"
   ],
   "typeRoots": [
     "../node_modules/@types"
   ]
 }
}

JohannesHoppe added a commit to angular-buch/book-monkey2 that referenced this issue Feb 28, 2017
@hannes-sandahl
Copy link

I have the same problem after upgrading from 32.8 to rc.0

@angular/cli: 1.0.0-rc.0
node: 6.9.3
os: win32 x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.8

e2e\app.e2e-spec.ts (12,5): Cannot find name 'expect'. (2304)
at getOutput (D:\Git\sok\node_modules\ts-node\src\index.ts:312:17)
at D:\Git\sok\node_modules\ts-node\src\index.ts:343:18
at Object.compile (D:\Git\sok\node_modules\ts-node\src\index.ts:476:19)
at Module.m._compile (D:\Git\sok\node_modules\ts-node\src\index.ts:406:44)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .ts] (D:\Git\sok\node_modules\ts-node\src\index.ts:409:12)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at D:\Git\sok\node_modules\jasmine\lib\jasmine.js:87:5
at Array.forEach (native)
at Jasmine.loadSpecs (D:\Git\sok\node_modules\jasmine\lib\jasmine.js:86:18)
at Jasmine.execute (D:\Git\sok\node_modules\jasmine\lib\jasmine.js:181:8)
at D:\Git\sok\node_modules\protractor\built\frameworks\jasmine.js:132:15
at Function.promise (D:\Git\sok\node_modules\q\q.js:682:9)
at D:\Git\sok\node_modules\protractor\built\frameworks\jasmine.js:104:14
at _fulfilled (D:\Git\sok\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\Git\sok\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\Git\sok\node_modules\q\q.js:796:13)
at D:\Git\sok\node_modules\q\q.js:556:49
at runSingle (D:\Git\sok\node_modules\q\q.js:137:13)
at flush (D:\Git\sok\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[10:33:23] E/launcher - Process exited with error code 100

@doggy8088
Copy link
Contributor

doggy8088 commented Mar 4, 2017

@filipesilva Do you know why typeRoots in the src/tsconfig.*.json been removed from rc.0? This will lead to old project unable to upgrade to new rc.0 or rc.1 version if they already included some @types .

Does the original typeRoots option can be default option in the further rc?

    "typeRoots": [
      "../node_modules/@types"
    ],

Also, there is an issue I found today.

#5034 (comment)

@filipesilva
Copy link
Contributor

typeRoots was removed in favor of listing types individually because:

  • it is safer overall to list types used, since each app will use different @types/ package
  • typeRoots should default to the correct top-level folder

I tried the repo provided and could verify the errors:

ng new -ng4 --routing --styles=scss hello
cd hello
ng e2e
//...
e2e\app.e2e-spec.ts (2,23): Cannot find name 'exports'. (2304)
e2e\app.e2e-spec.ts (3,18): Cannot find name 'require'. (2304)
e2e\app.e2e-spec.ts (4,1): Cannot find name 'describe'. (2304)
e2e\app.e2e-spec.ts (6,5): Cannot find name 'beforeEach'. (2304)
e2e\app.e2e-spec.ts (9,5): Cannot find name 'it'. (2304)
e2e\app.e2e-spec.ts (11,9): Cannot find name 'expect'. (2304)
//...

This doesn't happen with either ng build or ng test (which also uses node/jasmine typings), so it makes me think it's related to ts-node which is only used in protractor TS compilation. Perhaps inherited path resolution has a bug there.

Setting typeRoots on the root tsconfig.json seems to fix it for now as well. I'll open a bug on ts-node.

@filipesilva
Copy link
Contributor

I did a bunch of tests and it's not ts-node at all - it's typescript@~2.2. and also 2.3. So as far as I can tell it was an intended change where typeRoots is not inferred.

I'll put up a PR that adds it to the root tsconfig.json for --ng4 (and thus TS@^2.2) projects.

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Mar 6, 2017
TypeScript 2.2 does not infer `typeRoots`, so we need to list them explicitely in the root tsconfig.

Fix angular#5082
@filipesilva
Copy link
Contributor

I looked a bit more into it and it might be a ts-node bug after all... but only on windows. Tracking it in TypeStrong/ts-node#283

filipesilva added a commit that referenced this issue Mar 7, 2017
TS-Node with TypeScript 2.1+ does not infer `typeRoots`, so we need to list them explicitely in the root tsconfig.

Issue for TS-Node: TypeStrong/ts-node#283

Fix #5082
asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this issue Apr 12, 2017
TS-Node with TypeScript 2.1+ does not infer `typeRoots`, so we need to list them explicitely in the root tsconfig.

Issue for TS-Node: TypeStrong/ts-node#283

Fix angular#5082
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants