Issue
I have a angular project. Thus when I hit npm start I get the error:
> del-proj@0.0.0 build
> ng build
Node.js version v21.0.0 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/releases/.
⠼ Generating browser application bundles (phase: building)...
node:internal/event_target:1084
process.nextTick(() => { throw err; });
^
TypeError [Error]: Cannot read properties of undefined (reading 'indexOf')
at /home/user_name/project_path/node_modules/@angular-devkit/build-angular/node_modules/sass/sass.dart.js:104395:12
This is the project's dependencies
"dependencies": {
"@angular/animations": "^16.2.0",
"@angular/common": "^16.2.0",
"@angular/compiler": "^16.2.0",
"@angular/core": "^16.2.0",
"@angular/forms": "^16.2.0",
"@angular/platform-browser": "^16.2.0",
"@angular/platform-browser-dynamic": "^16.2.0",
"@angular/router": "^16.2.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "~16.2.6",
"@angular/cli": "^16.2.6",
"@angular/compiler-cli": "^16.2.0",
"@types/jasmine": "~4.3.0",
"jasmine-core": "~4.6.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",
"sass": "^1.69.4",
"typescript": "~5.1.3"
}
I deleted node_module folder, run npm i, then npm start and the error persists.
I hope someone would figure it out what is causing the problem.
Solution
Angular doesn't support odd versions of Node and Node20 support hasn't landed yet.
You should downgrade to node 18/use nvm
to set the node version to 18.
You can track the Node20 support on this issue.
Answered By - Matthieu Riegler
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.