Use paths mapping with tsconfig.e2e.json result to Cannot find module error
See original GitHub issueVersions
Angular CLI: 1.6.8
Node: 8.9.1
OS: win32 x64
Angular: 5.2.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
Done in 1.78s.
Windows 10
Repro steps
- Step 1 Declare new paths in tsconfig.e2e.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
],
"paths": {
"@mypath/*": [
"./mypath/*"
]
}
}
}
- Step 2 npm run ng e2e
Observed behavior
[12:13:32] E/launcher - Error: Error: Cannot find module '@myPath/path'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Projects\frontend\e2e\app.po.ts:2:1)
at Module._compile (module.js:635:30)
at Module.m._compile (C:\Projects\frontend\node_modules\ts-node\src\index.ts:422:23)
at Module._extensions..js (module.js:646:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Projects\frontend\node_modules\ts-node\src\index.ts:425:12)
at Module.load (C:\Projects\frontend\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Projects\frontend\e2e\app.e2e-spec.ts:1:1)
at Module._compile (module.js:635:30)
at Module.m._compile (C:\Projects\frontend\node_modules\ts-node\src\index.ts:422:23)
at Module._extensions..js (module.js:646:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Projects\frontend\node_modules\ts-node\src\index.ts:425:12)
at Module.load (C:\Projects\frontend\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at C:\Projects\frontend\node_modules\jasmine\lib\jasmine.js:93:5
at Array.forEach (<anonymous>)
at Jasmine.loadSpecs (C:\Projects\frontend\node_modules\jasmine\lib\jasmine.js:92:18)
at Jasmine.execute (C:\Projects\frontend\node_modules\jasmine\lib\jasmine.js:197:8)
at C:\Projects\frontend\node_modules\protractor\built\frameworks\jasmine.js:132:15
at Function.promise (C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:682:9)
at C:\Projects\frontend\node_modules\protractor\built\frameworks\jasmine.js:104:14
at _fulfilled (C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:556:49
at runSingle (C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:137:13)
at flush (C:\Projects\frontend\node_modules\protractor\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
[12:13:32] E/launcher - Process exited with error code 100
error Command failed with exit code 4.
Desired behavior
Paths should be resolved like expected in tsconfig
Mention any other details that might be useful (optional)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:14
Top Results From Across the Web
TypeScript: Error: Cannot find module when using paths
Right i carried on looking into this and i found a way to fix my issue. Here is the link, it explains it...
Read more >Angular-CLI with paths in tsconfig
I am configuring the paths property in the tsconfig.app.json... ... src/app/app.module.ts(8,33): error TS2307: Cannot find module '@app'.
Read more >Paths mapping | ts-jest - GitHub Pages
ts-jest provides a helper to transform the mapping from tsconfig to Jest config format, but it needs the .js version of the config...
Read more >cannot find module 'vuex' or its corresponding type declarations
I'm trying to set up tsconfig file for a vue app to take advantage of the paths property. The project started off initially...
Read more >TypeScript configuration - Angular
At the root tsconfig.json file specifies the base TypeScript and Angular compiler options that all projects in the workspace inherit. See the Angular...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Solution
e2e/tsconfig.e2e.json
protractor.conf.js
i’ve found the temporary solution:
My versions:
The solution is the usage of ‘tsconfig-paths’ package.
npm install tsconfig-paths --save-dev
protractor.conf.js
pathes
area intsconfig.json
*.e2e-spec.ts
and*.po.ts
files