You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
npm ERR! Unexpected token '.' with with nvm-windows <= 1.1.7 #4234
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
In this environment...
With this config...
Run '...'
See error...
I am using Windows 10 (Enterprise - Latest Version). I have the latest node and npm installed at the moment.
Reacted by Fabio Di Stasio, Abderrahman Cheddir, Kunalan Kevin Subagaran, Устинов Тихон Николаевич, Tito Merino, David, KAUSTAV BHATTACHARYA, Fábio Damasceno, xiansheng lu, Akif9748 and 37 more
Reacted by Roberto de León, Yahya Fati, Kushal, Steven Rogers, Russ, Dutch77, Pepo, Kunalan Kevin Subagaran, Happydev, CARLOS FRANCISCO GUTIERREZ TORIBIO and 1 more
Reacted by Oscar Eduardo Miramontes Raygoza, andender, Wazbat, Abderrahman Cheddir, Fábio Damasceno, stad-nico and Brian-Eclipse
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)
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):
updated nvm to 1.1.9 (did this using chocolatey, not using the .exe installer)
uninstalled both 16.14.0 and 16.17.0 versions of node
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.
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.
nvm install 'your prefered version' then nvm use 'the installed version'
Whoala!
Reacted by Gord Tranter, Eugene Melnik, mateuszseczkowski, Subhajit Nandi, jhlchu, Ashish Kumar, Filip Kinský, Simon Yang, iamoottoo, Kaswati and 1 more
Reacted by Oskar, fbrenes-wesco, razsinay, Miguel Ángel Rodríguez, Nick Medrano, João Heringer, Salvatore, iamoottoo and Nelson Mavare
Reacted by Wojtek Kosinski, Dmitry Shashkov, ihms, mateuszseczkowski, jhlchu, iamoottoo, Michael Hutchings and Juanj11o
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.
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.
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.
Activity
syedbilal07 commentedon Jan 14, 2022
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)
syedbilal07 commentedon Jan 14, 2022
Fixed it on my own. Please replace it with my version https://files.fm/u/sz3yrgsvj
dcodeIO commentedon Jan 18, 2022
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
syedbilal07 commentedon Jan 19, 2022
Facing this issue on npm install script too.
syedbilal07 commentedon Jan 19, 2022
27 verbose stack ../workspaces/libnpmfund
27 verbose stack ^
27 verbose stack
27 verbose stack SyntaxError: Unexpected token '.'
bonesoul commentedon Jan 19, 2022
same here..
bonesoul commentedon Jan 20, 2022
any fixes for this?
syedbilal07 commentedon Jan 20, 2022
Not yet. Waiting for the community member to resolve this
chore: exclude windows latest, see npm/cli#4234
feat: merge cli-ux library with oclif/core (#345)
ruyadorno commentedon Jan 27, 2022
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)
119 remaining items
mohammadmoth commentedon Jan 13, 2023
I deleted all versions of node 18, and then re-downloaded it, it works.
webdevatanas commentedon Jan 19, 2023
I am using windows and here is how I fixed it:
dosstx commentedon Feb 3, 2023
Fantastic step by step. THank you!
DevOps: upgrade Node.js version to 18.15.0
maurymmarques commentedon Apr 7, 2023
I've updated my node version and it worked.
Linux/macOS:
node -vnpm install -g nThis command will install a tool called "n" which you can use to update Node easily.
n latestThis command will install the latest version of Node on your system.
node -vcoreybutler commentedon Apr 8, 2023
@maurymmarques - n is a tool for Linux/macOS, not for Windows.
ci: update windows orbs to solve
natesire commentedon Jun 22, 2023
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.
natesire commentedon Jun 22, 2023
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.
natesire commentedon Jun 22, 2023
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
natesire commentedon Jun 23, 2023
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.
natesire commentedon Jun 23, 2023
#6601
Tan-nn commentedon Apr 30, 2024
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
carlosananias commentedon Jun 11, 2024
this is excellent... works well for my team