'Unexpected character '@' from [script.*.js]

When I try to production build angular, i encountered the error 'Unexpected character '@' [scripts.*.js]'. Production command ng build --prod

Angular version: 7.* Node modules used : 1. ag-grid



Solution 1:[1]

When anyone gets the error 'Unexpected character '@' [scripts..js]' or 'Unexpected token ',' [scripts..js]'. The above error could be from our code or the node_modules which we would have installed.

Error : You can see the error here

To find the source, execute the command ng build --prod --source-map

After executing source map, we can get the source file that causes error

enter image description here

The above command would point us to the file that causes the error while taking a production build.

If the command doesn't point to the source, please ensure that sourcemap=true in angular.json for production is true

Solution 2:[2]

this error occurs for eg. if you accidentally have a css-file in the scripts section in the angular.json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohan Stanky
Solution 2 agittarius