Skip to content

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

Closed

Description

@syedbilal07

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • 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:
; copy and paste output from `npm config ls` here

; "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.

Activity

  1. added
    Bugthing that needs fixing
    Needs Triageneeds review for next steps
    Release 8.xwork is associated with a specific npm 8 release
    on Jan 14, 2022
  2. syedbilal07 commented on Jan 14, 2022

    @syedbilal07
    Author

    27 verbose stack SyntaxError: Unexpected token '.'
    27 verbose stack at Object.compileFunction (node:vm:352:18)
    27 verbose stack at wrapSafe (node:internal/modules/cjs/loader:1026:15)
    27 verbose stack at Module._compile (node:internal/modules/cjs/loader:1061:27)
    27 verbose stack at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    27 verbose stack at Module.load (node:internal/modules/cjs/loader:975:32)
    27 verbose stack at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    27 verbose stack at Module.require (node:internal/modules/cjs/loader:999:19)
    27 verbose stack at require (node:internal/modules/cjs/helpers:102:18)
    27 verbose stack at Object. (C:\Program Files\nodejs\node_modules\npm\lib\commands\outdated.js:11:18)
    27 verbose stack at Module._compile (node:internal/modules/cjs/loader:1097:14)

  3. syedbilal07 commented on Jan 14, 2022

    @syedbilal07
    Author

    Fixed it on my own. Please replace it with my version https://files.fm/u/sz3yrgsvj

  4. dcodeIO commented on Jan 18, 2022

    @dcodeIO

    Seeing this issue on GitHub actions as well. Seems to be isolated to "windows" images running Node.js 17:

    https://github.com/AssemblyScript/assemblyscript/runs/4856320026?check_suite_focus=true#step:4:4

    OS: Microsoft Windows Server 2019 10.0.17763
    Node.js: 17.4.0
    npm: 8.3.1

  5. syedbilal07 commented on Jan 19, 2022

    @syedbilal07
    Author

    Facing this issue on npm install script too.

  6. syedbilal07 commented on Jan 19, 2022

    @syedbilal07
    Author

    27 verbose stack ../workspaces/libnpmfund
    27 verbose stack ^
    27 verbose stack
    27 verbose stack SyntaxError: Unexpected token '.'

  7. bonesoul commented on Jan 19, 2022

    @bonesoul

    same here..

  8. bonesoul commented on Jan 20, 2022

    @bonesoul

    any fixes for this?

  9. syedbilal07 commented on Jan 20, 2022

    @syedbilal07
    Author

    Not yet. Waiting for the community member to resolve this

  10. ruyadorno commented on Jan 27, 2022

    @ruyadorno
    Contributor

    hi @syedbilal07 it would be interesting to look at the log files to see understand better what could have happened there, if that's something you can provide us. (or anyone else having this issue)

  11. 119 remaining items

  12. mohammadmoth commented on Jan 13, 2023

    @mohammadmoth

    these are the versions that led me to this thread: nvm: 1.1.5 node: 16.14.0 npm: 8.3.1
    I was getting that nasty "Unexpected token '.'" error when trying to install, check version, and using npx (which was my main concern since I needed it for a script). I then tried switching versions:
    nvm: 1.1.5 node: 16.17.0 npm: 8.15.0
    I was still getting that error, so I did something similar to what @srsgores mentioned (all from a PowerShell command prompt running as Administrator):

    1. updated nvm to 1.1.9 (did this using chocolatey, not using the .exe installer)
    2. uninstalled both 16.14.0 and 16.17.0 versions of node
    3. reinstalled 16.17.0 version of node (latest LTS release at the moment of writing this comment)

    After that, everything was working correctly again. My guess is nvm's version was the culprit, but I'm not sure. I hope this is of use to someone.

    This resolved the issue for me, uninstalled the "nvm" installed using ".exe" file and reinstall using "chocolatey" and then install the node again and use that it will work (at least worked for me :)

    I deleted all versions of node 18, and then re-downloaded it, it works.

  13. webdevatanas commented on Jan 19, 2023

    @webdevatanas

    I am using windows and here is how I fixed it:

    1. Uninstall nvm from windows(you can do that from Add and remove programs). This will remove also the node versions installed with the nvm previously so you do not need manually to uninstall all before uninstall the whole nvm.
    2. Install the latest nvm from here https://github.com/coreybutler/nvm-windows/tags . 1.1.10 is the latest to this date.
    3. nvm install 'your prefered version' then nvm use 'the installed version'
    4. Whoala!
  14. dosstx commented on Feb 3, 2023

    @dosstx

    I am using windows and here is how I fixed it:

    1. Uninstall nvm from windows(you can do that from Add and remove programs). This will remove also the node versions installed with the nvm previously so you do not need manually to uninstall all before uninstall the whole nvm.
    2. Install the latest nvm from here https://github.com/coreybutler/nvm-windows/tags . 1.1.10 is the latest to this date.
    3. nvm install 'your prefered version' then nvm use 'the installed version'
    4. Whoala!

    Fantastic step by step. THank you!

  15. maurymmarques commented on Apr 7, 2023

    @maurymmarques

    I've updated my node version and it worked.

    Linux/macOS:

    1. Open the Terminal and check your current Node version:
      node -v
    2. Install n package using the following command:
      npm install -g n
      This command will install a tool called "n" which you can use to update Node easily.
    3. To update Node, run the following command in your terminal:
      n latest
      This command will install the latest version of Node on your system.
    4. Now you can verify that your update is complete by rechecking your Node version:
      node -v
  16. coreybutler commented on Apr 8, 2023

    @coreybutler

    @maurymmarques - n is a tool for Linux/macOS, not for Windows.

  17. added a commit that references this issue on Apr 12, 2023
  18. natesire commented on Jun 22, 2023

    @natesire

    If npm isn't working... then how can I use npm to fix itself. It's a circular problem. I cannot run any npm commands.

  19. natesire commented on Jun 22, 2023

    @natesire

    The easiest way to work around this is to either use Linux or the Ubuntu Subsystem on Windows to run your npm commands. And run with --verbose so you can see that it's the funding package libnpmfund that is tripping up over a path syntax error with the '.' on Windows.

  20. natesire commented on Jun 22, 2023

    @natesire

    It is happening with random npm packages. So that points to a problem with the npm code that calls out to these packages.

    at Module._compile (node:internal/modules/cjs/loader:1159:14

  21. natesire commented on Jun 23, 2023

    @natesire

    I found the root cause. These paths inside these files that the loader is requiring need double quoted. They are regular expressions too.

    Change
    ../workspaces/xxx

    To
    "../workspaces/xxx"

    in each file and it will work on Windows. I don't know why this is only breaking on Windows.

  22. natesire commented on Jun 23, 2023

    @natesire
  23. Tan-nn commented on Apr 30, 2024

    @Tan-nn

    I faced issues with nvm 1.1.7, Solved this issue when updated to 1.1.12, but I can not uninstall nvm 1.1.7 only copy and replace file

  24. carlosananias commented on Jun 11, 2024

    @carlosananias

    A versão 1.1.10 do NVM tem todos esses problemas (mais o problema de elevação) corrigidos. Atualize o nvm e, em seguida, remova as versões do nó quebrado e reinstale-as.

    Agora tudo funciona conforme o esperado.

    this is excellent... works well for my team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions