FG
🛠️ Developer ToolsMicrosoft

npm ERR! Unexpected token '.' with with nvm-windows <= 1.1.7

Freshabout 19 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

Is there an existing issue for this? - [X] I have searched the existing issues This issue exists in the latest npm version - [X] I am using the latest npm Current Behavior I have updated to the latest npm v8.3.1 and it is showing me an error while using the command "npm outdated -g --depth=0". See the image; https://imgur.com/a/5fMZlye. It was fine on v8.3.0. What is the solution? Expected Behavior It should return the outdated packages after a successful run. But it is giving error. Steps To Reproduce 1. In this environment... 2. With this config... 3. Run '...' 4. See error... I am using Windows 10 (Enterprise - Latest Version). I have the latest node and npm installed at the moment. Environment - npm: - Node.js: - OS Name: - System Model Name: - npm config: [code block] ; "user" config from C:\Users\Bilal\.npmrc registry = "http://registry.npmjs.org/" ; node bin location = C:\Program Files\nodejs\node.exe ; cwd = C:\Users\Bilal ; HOME = C:\Users\Bilal ; Run `npm config ls -l` to show all defaults.

Error Output

error while using the command "npm outdated -g --depth=0". See the image; https://imgur.com/a/5fMZlye. It was fine on v8.3.0. What is the solution?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix npm ERR! Unexpected token '.' in nvm-windows <= 1.1.7

Medium Risk

The error 'Unexpected token' occurs due to a parsing issue in the npm command when using certain versions of nvm-windows (<= 1.1.7) in conjunction with npm v8.3.1. This is likely caused by changes in npm's output format that are not properly handled by the older nvm-windows versions.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update nvm-windows

    Upgrade nvm-windows to the latest version to ensure compatibility with the latest npm. This will resolve parsing issues that may arise from outdated nvm-windows versions.

    bash
    nvm install latest
  2. 2

    Verify Node.js and npm versions

    Check that you are using the correct versions of Node.js and npm after updating nvm. This ensures that the environment is correctly set up.

    bash
    node -v && npm -v
  3. 3

    Clear npm cache

    Clear the npm cache to remove any corrupted or outdated cached data that may be causing issues with npm commands.

    bash
    npm cache clean --force
  4. 4

    Run npm outdated command

    After updating nvm and clearing the npm cache, run the 'npm outdated -g --depth=0' command again to check for outdated global packages.

    bash
    npm outdated -g --depth=0

Validation

Confirm that the command 'npm outdated -g --depth=0' runs successfully without any errors. The output should list any outdated global packages without showing the 'Unexpected token' error.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

npmpackage-managernodejsrelease-8.xbug