Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Running npx globally does not work on Windows when the user folder patch contains a space #146

@GrimzEcho

Description

@GrimzEcho

This may be related to issue #110, but I believe it is separate. However, I have tried the various fixes suggested in that thread.

When running npx (with any arguments, but -v is easiest to test) from the global install folder, the following error is produced.

npm ERR! code ENOLOCAL
npm ERR! Could not install from "Echo\AppData\Roaming\npm-cache\_npx\14184" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Grim Echo\AppData\Roaming\npm-cache\_logs\2018-01-03T00_26_34_241Z-debug.log

It seems that npx is not properly escaping any spaces contained in the npm config prefix variable.

$ npm config list
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.5.1 node/v9.3.0 win32 x64"

; userconfig C:\Users\Grim Echo\.npmrc
prefix = "C:\\Users\\Grim Echo\\AppData\\Roaming\\npm"

; builtin config undefined

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = D:\gdrive\Projects\Web\React\test_1
; HOME = C:\Users\Grim Echo
; "npm config ls -l" to show all defaults.

The full error log file

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'prefix@latest',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Users\\Grim',
1 verbose cli   'Echo\\AppData\\Roaming\\npm-cache\\_npx\\16608',
1 verbose cli   '--loglevel',
1 verbose cli   'error',
1 verbose cli   '--json' ]
2 info using npm@5.5.1
3 info using node@v9.3.0
4 verbose npm-session 276140a6271ea49d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Echo\AppData\Roaming\npm-cache\_npx\16608 Could not install from "Echo\AppData\Roaming\npm-cache\_npx\16608" as it does not contain a package.json file.
8 http fetch GET 200 https://registry.npmjs.org/prefix 46ms (from cache)
9 silly pacote tag manifest for prefix@latest fetched in 87ms
10 verbose stack Error: ENOENT: no such file or directory, open 'D:\gdrive\Projects\Web\React\test_1\Echo\AppData\Roaming\npm-cache\_npx\16608\package.json'
11 verbose cwd D:\gdrive\Projects\Web\React\test_1
12 verbose Windows_NT 10.0.16299
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "prefix@latest" "--global" "--prefix" "C:\\Users\\Grim" "Echo\\AppData\\Roaming\\npm-cache\\_npx\\16608" "--loglevel" "error" "--json"
14 verbose node v9.3.0
15 verbose npm  v5.5.1
16 error code ENOLOCAL
17 error Could not install from "Echo\AppData\Roaming\npm-cache\_npx\16608" as it does not contain a package.json file.
18 verbose exit [ 1, true ]

Note lines 1, 13, and 17.

Notice how the path is split on lines 1, and how the space is improperly escaped on line 13. The entire path needs to be in a string, but npx seems to be splitting it into two strings.

This issue seems specific to npx, as other npm commands seem to use the prefix directory correctly.

This is running npx 9.6.0 on node 9.3.0 on Windows 10.

The issue does not happen when the user directory contains no spaces, or when running npx locally from within a project folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions