-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm ERR! Unexpected token '.' with with nvm-windows <= 1.1.7 #4234
Comments
27 verbose stack SyntaxError: Unexpected token '.' |
Fixed it on my own. Please replace it with my version https://files.fm/u/sz3yrgsvj |
Seeing this issue on GitHub actions as well. Seems to be isolated to "windows" images running Node.js 17: OS: Microsoft Windows Server 2019 10.0.17763 |
Facing this issue on npm install script too. |
27 verbose stack ../workspaces/libnpmfund |
same here.. |
any fixes for this? |
Not yet. Waiting for the community member to resolve this |
* feat: merge cli-ux library with oclif/core Removes the circlular dependency between oclif/core and cli-ux @W-10255961@ * chore: fix relative paths * feat: merge cli-ux library with oclif/core Removes the circlular dependency between oclif/core and cli-ux * v1.1.2-test-02 * chore: resolve name collision for core/Config and cli-ux/Config * chore: revert to latest version number * chore: fix build error * chore: fix imports in tests * chore: wrap cli-ux exported members in namespace * chore: remove unneeded import * Revert "chore: remove unneeded import" This reverts commit 8d2f1ec. * Revert "chore: wrap cli-ux exported members in namespace" This reverts commit 905e5d5. * chore: rework cliux namespace export * chore: document migration * chore: apply suggestions from code review Co-authored-by: Juliet Shackell <[email protected]> * chore: remove unneeded console.log statement * chore: update migration guide * chore: fix up examples * chore: apply review suggestions * chore: adjust exports * chore: abandon use of namesapce * v1.1.2-test-07 * v1.1.2-test-08 * v1.1.2-test-09 * chore: remove use of lodash/castArray * chore: exclude windows latest, see npm/cli#4234 * fix: integration test command in ci config * chore: fix integration test job name Co-authored-by: Juliet Shackell <[email protected]> Co-authored-by: Rodrigo Espinosa de los Monteros <[email protected]>
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) |
I don't know if there is a way to look at the logs in github actions but here is one that is failing. https://github.com/coffeelint/coffeelint/runs/4960440881
|
The log files for the error: log file0 verbose cli [ 0 verbose cli 'C:\\Program Files\\nodejs\\node.exe', 0 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 0 verbose cli 'install' 0 verbose cli ] 1 info using [email protected] 2 info using [email protected] 3 timing npm:load:whichnode Completed in 0ms 4 timing config:load:defaults Completed in 2ms 5 timing config:load:file:C:\Users\halcw\AppData\Roaming\nvm\v17.4.0\node_modules\npm\npmrc Completed in 24ms 6 timing config:load:builtin Completed in 24ms 7 timing config:load:cli Completed in 2ms 8 timing config:load:env Completed in 0ms 9 timing config:load:file:C:\Development\halcwb\apps\GenPres2\.npmrc Completed in 0ms 10 timing config:load:project Completed in 3ms 11 timing config:load:file:C:\Users\halcw\.npmrc Completed in 0ms 12 timing config:load:user Completed in 0ms 13 timing config:load:file:C:\Program Files\nodejs\etc\npmrc Completed in 1ms 14 timing config:load:global Completed in 1ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:credentials Completed in 1ms 17 timing config:load:setEnvs Completed in 1ms 18 timing config:load Completed in 36ms 19 timing npm:load:configload Completed in 36ms 20 timing npm:load:setTitle Completed in 1ms 21 timing config:load:flatten Completed in 3ms 22 timing npm:load:display Completed in 5ms 23 verbose logfile C:\Users\halcw\AppData\Local\npm-cache\_logs\2022-01-26T17_31_57_523Z-debug-0.log 24 timing npm:load:logFile Completed in 52ms 25 timing npm:load:timers Completed in 0ms 26 timing npm:load:configScope Completed in 0ms 27 timing npm:load Completed in 94ms 28 verbose stack C:\Users\halcw\AppData\Roaming\nvm\v17.4.0\node_modules\npm\node_modules\libnpmfund:1 28 verbose stack ../workspaces/libnpmfund 28 verbose stack ^ 28 verbose stack 28 verbose stack SyntaxError: Unexpected token '.' 28 verbose stack at Object.compileFunction (node:vm:352:18) 28 verbose stack at wrapSafe (node:internal/modules/cjs/loader:1026:15) 28 verbose stack at Module._compile (node:internal/modules/cjs/loader:1061:27) 28 verbose stack at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10) 28 verbose stack at Module.load (node:internal/modules/cjs/loader:975:32) 28 verbose stack at Function.Module._load (node:internal/modules/cjs/loader:822:12) 28 verbose stack at Module.require (node:internal/modules/cjs/loader:999:19) 28 verbose stack at require (node:internal/modules/cjs/helpers:102:18) 28 verbose stack at Object. (C:\Users\halcw\AppData\Roaming\nvm\v17.4.0\node_modules\npm\lib\utils\reify-output.js:16:38) 28 verbose stack at Module._compile (node:internal/modules/cjs/loader:1097:14) 29 verbose cwd C:\Development\halcwb\apps\GenPres2 30 verbose Windows_NT 10.0.19043 31 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" 32 verbose node v17.4.0 33 verbose npm v8.3.1 34 error Unexpected token '.' 35 verbose exit 1 36 timing npm Completed in 308ms 37 verbose code 1 38 error A complete log of this run can be found in: 38 error C:\Users\halcw\AppData\Local\npm-cache\_logs\2022-01-26T17_31_57_523Z-debug-0.logOn my machine: Luckily I use nvm so I could easily revert back to node 17.3.1. |
Hi @ruyadorno, I am now using npm v8.3.0 with node 17.4.0. I cannot provide the full log right now and I do not want to upgrade to npm v8.3.2. Please check the logs on your end and run tests on Github so you can figure it out. I have provided stack trace of the issue above. I think that could help. |
I had a similar issue when using |
Heya @syedbilal07 was this actually fixed or did you just close it because you're using your own workaround? |
use the newest version of npm and u should be fine. just skip 8.3.1. |
I also have the same issue, using nvm for Windows (Node 17.4.0, npm 8.3.1).
|
how to do that? to update npm you need npm. |
I finally used the latest Node.js LTS, 16.3.2, and it worked. |
Yesterday node v16.14.0 (latest LTS) was released, and it includes npm v8.3.1 so there's no way to make npm update itself. |
Just ran in the same issue with node 16.14.0. You can download 8.3.2 tgz file and manually replace npm in your node_modules directory of the node version you have. |
Similar issue for v16.17.0. |
This issue was fixed with nvm 1.1.9. See @TGTGamer reply for instructions. |
It works! |
Upgrading to nvm 1.1.9. did not immediately fix the issue for me, I had to uninstall and reinstall the broken node version.
|
@TGTGamer already outlined this. :) |
I'm also having this issue, it seems like this problem started with version 8.3.1. |
Can confirm in current NPM build this is a problem. |
NVM Version 1.1.10 has all these problems (plus the elevation problem) fixed. Everything now works as expected. |
in my case I fix it uninstalling nvm and all versions of node and install everything again via chocolatey, nvm (latest version) and node 16.13.0 and works as expected. |
This is the solution! |
This resolved the issue for me, uninstalled the "nvm" installed using ".exe" file and reinstall using "chocolatey" |
The above works for me as well. |
I deleted all versions of node 18, and then re-downloaded it, it works. |
I am using windows and here is how I fixed it:
|
Fantastic step by step. THank you! |
The use of lint-staged requires a newer version of Node.js. Additionally, with this version, the [nvm bug that lead to failing `npm install`](npm/cli#4234 (comment)) seems to be fixed.
I've updated my node version and it worked. Linux/macOS:
|
@maurymmarques - n is a tool for Linux/macOS, not for Windows. |
Summary: Currently we use `nvm install 16` in the `test_windows` CircleCI job. With the "official" non-Windows NVM, this means latest 16 (16.17.0), but that's not the case for NVM-Windows, [which simply appends `.0.0`](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L384) unless [the major version is one character long](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L210). The Windows orb includes NVM-Windows 1.1.7 (even on the latest 5.0.0 orb), which does not support `nvm install lts` (added 1.1.9). Updating NVM isn't trivial as the system/orb version takes precedence over any Chocolately installation. Running tests on 16.0.0 blocks Jest 29, which requires [`^16.10.0`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-create-cache-key-function/package.json#L17). I initially tried installing a specific Node JS version with NVM, but NVM-Windows 1.1.7 doesn't support newer Node versions due to npm/cli#4234. So this PR switches from using NVM-Windows to just using Chocolately Node JS packages. `nodejs-lts` tracks the latest LTS. IMO, given we're only testing against one Node JS version with Windows, the latest LTS is a good option, but versions can be specified with `--version` if we want to pin it instead. Yarn is available through [corepack](https://nodejs.org/api/corepack.html#corepack) since 16.9, so doesn't need to be installed separately. ## Changelog [Internal] [Fixed] - CircleCI: Update Node JS version used on Windows tests from 16.0.0 to 16.17.0 Pull Request resolved: facebook#34726 Test Plan: Tested via painful trial and error on my fork: https://app.circleci.com/pipelines/github/robhogan/react-native/19/workflows/0c23a77f-40d2-4c36-933b-53c14acb7907 Reviewed By: cipolleschi Differential Revision: D39647377 Pulled By: robhogan fbshipit-source-id: 733da49c632eab26a09ba9cd0175419b9144f9d2
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. |
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. |
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 |
I found the root cause. These paths inside these files that the loader is requiring need double quoted. They are regular expressions too. Change To in each file and it will work on Windows. I don't know why this is only breaking on Windows. |
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 |
this is excellent... works well for my team |
Is there an existing issue for this?
This issue exists in the latest npm version
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
I am using Windows 10 (Enterprise - Latest Version). I have the latest node and npm installed at the moment.
Environment
; 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.The text was updated successfully, but these errors were encountered: