Node.js / NPM Error [index.js:1 SyntaxError: Invalid or unexpected token]

917 Views Asked by At

I have an issue on Windows, and none of previous solutions solves my problem.

Even uninstalling then reinstalling did not resolve the issue.

This happened after executing .bat file called: "Install Additional Tools for Node.js" which contains some Windows updates and Visual Studio 2019 stuff.

Here is the error output message with any npm command:


C:\> npm install ANYTHING                                                                                     
C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\ci-detect\index.js:1                        
                                                     
SyntaxError: Invalid or unexpected token                                                                              
    at Object.compileFunction (node:vm:355:18)                                                                        
    at wrapSafe (node:internal/modules/cjs/loader:1022:15)                                                            
    at Module._compile (node:internal/modules/cjs/loader:1056:27)                                                     
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)                                       
    at Module.load (node:internal/modules/cjs/loader:972:32)                                                          
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)                                                
    at Module.require (node:internal/modules/cjs/loader:996:19)                                                       
    at require (node:internal/modules/cjs/helpers:92:18)                                                              
    at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\lib\utils\config\definitions.js:7:18) 
    at Module._compile (node:internal/modules/cjs/loader:1092:14)                                                     
                                                                                            

                      
0

There are 0 best solutions below