Unexpected token ‘.’ when trying to run ‘npm install’

We Are Going To Discuss About Unexpected token ‘.’ when trying to run ‘npm install’. So lets Start this Angular Article.

Unexpected token ‘.’ when trying to run ‘npm install’

How to solve Unexpected token ‘.’ when trying to run ‘npm install’

This is a reported issue for npm version 8.3.1.
Your best bet is to skip this version (Either use 8.3.2 or 8.4), use an earlier version (8.3.0) or use another node version (< 17).

Unexpected token ‘.’ when trying to run ‘npm install’

This is a reported issue for npm version 8.3.1.
Your best bet is to skip this version (Either use 8.3.2 or 8.4), use an earlier version (8.3.0) or use another node version (< 17).

Solution 1

This is a reported issue for npm version 8.3.1.

Your best bet is to skip this version (Either use 8.3.2 or 8.4), use an earlier version (8.3.0) or use another node version (< 17).

Original Author Philipp Meissner Of This Content

Solution 2

Had this issue on Win 10, npm 8.1.2, node 16.14.2, nvm 1.1.17 and 1.1.19.
Downgrading to node 16.13.2 fixed the problem as per this answer: https://github.com/npm/cli/issues/4234#issuecomment-1025421643

Original Author Shimi Shimson Of This Content

Solution 3

The main problem is that, if you try to follow the steps to install angular, you will inevitably run into this error, because the recommended version of node.js is 16.14.0, and node already tells you that it comes with 8.3.1 node version:
captura de pantalla de node.js con la versión recomendada de node

To solve this problem, you can install node versión 16.13.2, that comes with npm 8.1.2 version (instead of 8.1.3), as it is said here: https://nodejs.org/en/download/releases/

Note: I use nvm

Then you could install angular.

Another possibility, if you want to use angular with node 16.14.0, could be to upgrade the npm version. The problem is that, when you try to do so, it will arise the same error that appeared when you tried to install angular.

To solve this, I recommend this:

a) Install a previous version of node that uses another version of npm, as node 16.13.2, that comes with npm 8.1.2. Personally I have several versions of node through nvm (node version manager) for windows.

b) Copy the npm package of this node installation of node 16.13.2, and change it into the folder of the node 16.14.0 (delete or rename old npm folder before).

c) Use node 16.14.0 typing nvm use 16.4.0

d) Upgrade npm typing npm install -g [email protected]

Here you could see the sequence:

First, rename npm 8.1.3 and paste npm 8.1.2:
Muestra cómo quedan las carpetas con el npm

Then, you can see here the commands in the MS-DOS console:

C:\Users\AB>npm -v
    8.1.2

 
C:\Users\AB>npm version
    {
      npm: '8.1.2',
      node: '16.14.0',
      v8: '9.4.146.24-node.20',
      uv: '1.43.0',
      zlib: '1.2.11',
      brotli: '1.0.9',
      ares: '1.18.1',
      modules: '93',
      nghttp2: '1.45.1',
      napi: '8',
      llhttp: '6.0.4',
      openssl: '1.1.1m+quic',
      cldr: '40.0',
      icu: '70.1',
      tz: '2021a3',
      unicode: '14.0',
      ngtcp2: '0.1.0-DEV',
      nghttp3: '0.1.0-DEV'
    }
     

C:\Users\AB>npm install -g [email protected]
  
    removed 186 packages, changed 19 packages, and audited 36 packages in 25s
       
found 0 vulnerabilities
     

C:\Users\AB>npm version

{
      npm: '8.5.2',
      node: '16.14.0',
      v8: '9.4.146.24-node.20',
      uv: '1.43.0',
      zlib: '1.2.11',
      brotli: '1.0.9',
      ares: '1.18.1',
      modules: '93',
      nghttp2: '1.45.1',
      napi: '8',
      llhttp: '6.0.4',
      openssl: '1.1.1m+quic',
      cldr: '40.0',
      icu: '70.1',
      tz: '2021a3',
      unicode: '14.0',
      ngtcp2: '0.1.0-DEV',
      nghttp3: '0.1.0-DEV'
    }
        
C:\Users\AB>npm install -g @angular/cli
        
added 189 packages, and audited 191 packages in 1m
             found 0 vulnerabilities

     
C:\Users\AB>ng version
   
         _                      _                 ____ _     ___
        / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
       / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
      / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
    /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                    |___/

 

 
    Angular CLI: 13.2.5
    Node: 16.14.0
    Package Manager: npm 8.5.2
    OS: win32 x64
     

Angular:
   
    Package                      Version
    ------------------------------------------------------
    @angular-devkit/architect    0.1302.5 (cli-only)
    @angular-devkit/core         13.2.5 (cli-only)
    @angular-devkit/schematics   13.2.5 (cli-only)
    @schematics/angular          13.2.5 (cli-only)

Original Author Antonio B Of This Content

Solution 4

Some other answers here are probably right. I didn’t bother to investigate and tried yarn.

In my case I got the “Unexpected token ‘.'” error when installing npm-check-updates and fixed that by installing it using yarn.

yarn global add npm-check-updates

Original Author Christiaan Westerbeek Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment