ERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'zone.js/dist/zone'
Solution 1
I found out that my test configurations on tsconfig.spec.json
were wrong. So I change from this:
{
"extends": "./tsconfig.es5.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es6",
"baseUrl": "",
"types": [
"jest",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
to this:
{
"extends": "./tsconfig.es5.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../out-tsc/spec",
"module": "commonjs",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
And the error disapeared!
Solution 2
I fixed it in my project with this command:
npm install [email protected] --save
I was getting this error using [email protected]
.
Ricardo Rocha
🧐 Who is this man? 💻 Full Stack Web Developer and in love with javascript and everything around. 👨💻 Works daily with C#, angular, and SQL and likes it! ✨ Deep learning enthusiastic, especially if works with javascript 😀 📚 Learn addicted. 🤓 Proud nerd! 🎷 Saxophone player.
Updated on June 25, 2022Comments
-
Ricardo Rocha almost 2 years
I have an angular 8, that uses karma/jasmine to run some unit tests. I can run tests by executing the following command
ng test
but I'm getting the following error:ERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'zone.js/dist/zone' in 'C:\PrjNET\Elevation3\FW\4.00\Project\Framework\Development\Client\ElevationJS\shell\src' resolve 'zone.js/dist/zone' in 'C:\PrjNET\Elevation3\FW\4.00\Project\Framework\Development\Client\ElevationJS\shell\src'
Any one know how to solve it?
-
djangofan over 3 yearsThis answer doesn't help much without knowing your effective combined configuraiton.