Skip to content
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

Unexpected token '.' when running npm install with node 17.4.0 and explicit npm installation #310

Open
Maxim-Mazurok opened this issue Jun 23, 2022 · 3 comments

Comments

@Maxim-Mazurok
Copy link
Contributor

On windows 11 I can't use npm with node 17.4.0 when I explicitly ask to install npm 8.3.1 (which is shipped with this node version by default):

C:\Users\maxim\my-project>python -m nodeenv nodeenv --node=17.4.0 --npm=8.3.1 --with-npm
 * Install prebuilt node (17.4.0) ..... done.
symbolic link created for nodeenv\Scripts\nodejs.exe <<===>> node.exe
 * Install npm.js (8.3.1) ...
C:\Users\maxim\my-project>nodeenv\Scripts\activate.bat   
(nodeenv) C:\Users\maxim\my-project>node -v
v17.4.0

(nodeenv) C:\Users\maxim\my-project>npm -v
8.3.1

(nodeenv) C:\Users\maxim\my-project>npm install something
npm ERR! Unexpected token '.'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\maxim\AppData\Local\npm-cache\_logs\2022-06-23T12_13_38_115Z-debug-0.log

(nodeenv) C:\Users\maxim\my-project>

Here's a complete log:

0 verbose cli [
0 verbose cli   'C:\\Users\\maxim\\my-project\\nodeenv\\Scripts\\node.exe',
0 verbose cli   'C:\\Users\\maxim\\my-project\\nodeenv\\Scripts\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'install',
0 verbose cli   'something'
0 verbose cli ]
1 info using npm@8.3.1
2 info using node@v17.4.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\maxim\my-project\nodeenv\Scripts\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\maxim\my-project\.npmrc Completed in 2ms
10 timing config:load:project Completed in 3ms
11 timing config:load:file:C:\Users\maxim\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\maxim\my-project\nodeenv\Scripts\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 12ms
19 timing npm:load:configload Completed in 12ms
20 timing npm:load:setTitle Completed in 0ms
21 timing config:load:flatten Completed in 2ms
22 timing npm:load:display Completed in 3ms
23 verbose logfile C:\Users\maxim\AppData\Local\npm-cache\_logs\2022-06-23T12_13_38_115Z-debug-0.log
24 timing npm:load:logFile Completed in 6ms
25 timing npm:load:timers Completed in 0ms
26 timing npm:load:configScope Completed in 0ms
27 timing npm:load Completed in 23ms
28 verbose stack C:\Users\maxim\my-project\nodeenv\Scripts\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.<anonymous> (C:\Users\maxim\my-project\nodeenv\Scripts\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:\Users\maxim\my-project
30 verbose Windows_NT 10.0.22000
31 verbose argv "C:\\Users\\maxim\\my-project\\nodeenv\\Scripts\\node.exe" "C:\\Users\\maxim\\my-project\\nodeenv\\Scripts\\node_modules\\npm\\bin\\npm-cli.js" "install" "something"
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 267ms
37 verbose code 1
38 error A complete log of this run can be found in:
38 error     C:\Users\maxim\AppData\Local\npm-cache\_logs\2022-06-23T12_13_38_115Z-debug-0.log

Here's a very similar issue with nvm4w: coreybutler/nvm-windows#814

This works:

python -m nodeenv nodeenv --node=17.4.0
npm install -g npm@8.3.1
npm install something
@Maxim-Mazurok
Copy link
Contributor Author

Another example: node 18.3.0 and npm 8.3.1.

Doesn't work when installed using nodeenv, but if I install node using nodeend, activate env, then run npm i -g npm@8.3.1 - it works fine.

@vitorgamer58
Copy link

The same here with node 16.14.2

I've changed my node version with nvm to 16.12.0 and the problem was fixed.

@cjablonski76
Copy link

cjablonski76 commented Mar 7, 2023

Posted what fixed this for me here:
coreybutler/nvm-windows#814 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants