node
node copied to clipboard
'ERR_INTERNAL_ASSERTION' Using DOTENV plugin in Angular: 17.3.0and NodeJs v20.13.1
Version
v20.13.1
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
After trying to implement custom-webpack in Angular frontend. Able to resolve loaders which initially throwing an exception but now, it only shows an Internal error which I believe maybe a compatibility issue of dotenv and Node.js? Not sure. Below are the steps to reproduce.
angular.json
(added)
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./config/customs/webpack.config.mjs"
},
webpack.config.mjs
import Dotenv from 'dotenv-webpack';
export default {
module: {
rules: [
{
test: /\.(scss|css|js)$/i,
use: ["style-loader", "css-loader", "sass-loader", "val-loader"],
}
]
},
plugins: [
new Dotenv({
path: './.env', // Path to .env file
safe: false, // Load .env.example (defaults to "false" which does not use dotenv-safe)
}),
],
};
globals.d.ts
// src/globals.d.ts
declare var process: {
env: {
[key: string]: string;
};
};
package.json
(added dependencies)
"devDependencies": {
"@angular-builders/custom-webpack": "^17.0.2",
"@angular-devkit/build-angular": "^17.3.0",
"@angular/cli": "^17.3.0",
"@angular/compiler-cli": "^17.3.0",
"@types/jasmine": "~5.1.0",
"css-loader": "^7.1.1",
"dotenv-webpack": "^8.1.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"style-loader": "^4.0.0",
"ts-loader": "^9.5.1",
"typescript": "~5.4.2",
"val-loader": "^6.0.0",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
}
How often does it reproduce? Is there a required condition?
after the changes and installing the dependencies, when ng build
error shows below
Error [ERR_INTERNAL_ASSERTION]: Unknown worker message type message
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at Function.fail (node:internal/assert:20:9)
at [kOnMessage] (node:internal/worker:354:12)
at MessagePort.<anonymous> (node:internal/worker:232:57)
at _ZoneDelegate.invokeTask (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:403:31)
at Zone.runTask (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:174:47)
at ZoneTask.invokeTask [as invoke] (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:484:34)
at invokeTask (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:1645:18)
at globalCallback (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:1676:29)
at MessagePort.globalZoneAwareCallback (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:1709:16)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:825:20)
code: 'ERR_INTERNAL_ASSERTION'
What is the expected behavior? Why is that the expected behavior?
I was expecting that I am going successfully build and run the frontend and to call the external information from .env
file related to URL and port, however this issue prevents from building
What do you see instead?
Error [ERR_INTERNAL_ASSERTION]: Unknown worker message type message
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at Function.fail (node:internal/assert:20:9)
at [kOnMessage] (node:internal/worker:354:12)
at MessagePort.<anonymous> (node:internal/worker:232:57)
at _ZoneDelegate.invokeTask (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:403:31)
at Zone.runTask (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:174:47)
at ZoneTask.invokeTask [as invoke] (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:484:34)
at invokeTask (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:1645:18)
at globalCallback (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:1676:29)
at MessagePort.globalZoneAwareCallback (C:\L&D\frontend\node_modules\zone.js\fesm2015\zone.js:1709:16)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:825:20)
code: 'ERR_INTERNAL_ASSERTION'
Additional information
The target implementation is to utilize dotenv to externalize configuration . Is there a compatibility issues between Node.js, Angular, and dotenv versions?