TypeScript - importing package failed on "Module parse failed: Unexpected token"
See original GitHub issueCurrent behavior
I import npm package with additional functions and I get error:
Error: Webpack Compilation Error
../node_modules/cypress-somecompany-utils/src/env.ts 1:22
Module parse failed: Unexpected token (1:22)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> export function getEnv<TEnv, K extends keyof TEnv>(key: K): TEnv[K] {
.
.
.
I do not face this issue when I use @cypress/webpack-preprocessor. My target is to get rid of this preprocessor to increase build performance.
Desired behavior
I can import typescript packages.
Test code to reproduce
import * as utils from “cypress-somecompany-utils”;
Cypress Version
8.4.1
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Webpack failed to parse TypeScript module: Unexpected token
From what I can see, the module parsing error points to a line in my index.ts file. However, this file has no syntax...
Read more >Module parse failed: Unexpected token Emberjs - Build Issues
I currently have an issue in an addon which I'm trying to convert to an Emberjs addon to the V2 version. It's a...
Read more >module parse failed: unexpected token (1:0) you may need an ...
Answer. The root cause is that your Typescript rule isn't matching (“currently no loaders are configured to process this file”), so Webpack is...
Read more >Internal Packages - Turborepo
ts Module parse failed: Unexpected token (1:21) You may need an appropriate loader to handle this file type, currently no loaders are configured ......
Read more >TypeStrong/ts-loader - Gitter
I'm using Typescript 2.0.3, with ts-loader 0.8.2 and webpack 1.13.2, ... Module parse failed: Unexpected token (2:9) You may need an appropriate loader...
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 FreeTop 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
Top GitHub Comments
Just chiming in on this. I got this error after the target on my main
tsconfig.json
was changed to a later target thanes5
. My Cypresstsconfig.jsoon
inherits from that file and so I got the error. I simply overrode the target for Cypress and set it back toes5
.Closing because of the inactivity.