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

npx doesn't work at all on Windows if spaces are in the path to npm-cache #276

Open
Stabilostick opened this issue Sep 5, 2019 · 4 comments
Labels
external This is not a problem of the creator or the adapter template

Comments

@Stabilostick
Copy link

Stabilostick commented Sep 5, 2019

If spaces are in the path to npm-cache you always get the following error when executing npx:

C:\dev\adapter>npx @iobroker/create-adapter
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Files\iobroker\SmartHome17\env\npm-cache\_npx\2772" as it does not contain a package.json file.

In this case the path to npm-cache was 'C:\Program Files\iobroker\SmartHome17\env\npm-cache'.

More logging:

1 verbose cli [ 'C:\\Program Files\\iobroker\\SmartHome17\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\iobroker\\SmartHome17\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '@iobroker/create-adapter@latest',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Program',
1 verbose cli   'Files\\iobroker\\SmartHome17\\env\\npm-cache\\_npx\\8336',
2 info using [email protected]
3 info using [email protected]
7 silly fetchPackageMetaData error for file:Files\iobroker\SmartHome17\env\npm-cache\_npx\8336 Could not install from "Files\iobroker\SmartHome17\env\npm-cache\_npx\8336" as it does not contain a package.json file.
12 verbose stack Error: ENOENT: no such file or directory, open 'C:\dev\adapter\Files\iobroker\SmartHome17\env\npm-cache\_npx\8336\package.json'
14 verbose Windows_NT 10.0.17134
15 verbose argv "C:\\Program Files\\iobroker\\SmartHome17\\nodejs\\node.exe" "C:\\Program Files\\iobroker\\SmartHome17\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@iobroker/create-adapter@latest" "--global" "--prefix" "C:\\Program" "Files\\iobroker\\SmartHome17\\env\\npm-cache\\_npx\\8336" "--loglevel" "error" "--json"

NOTE: Why the weird escape condition? Because the child.spawn npm always runs in shell mode when on Windows (it's the default, to prevent weird behavior). That means that arguments to npm need to be escaped (but as strings, not as paths).
The regular unix invocation doesn't need escaping, because it doesn't run in shell mode.

npx GitHub issues:
zkat/npx#146 - workaround, not solved, closed
zkat/npx#100 - open, since July 2017
zkat/npx#223 - open, is npx project dead?
npm/npx#6

Solution:
zkat/npx#181 - open since May 2018

@Stabilostick Stabilostick changed the title npx doesn't work at all if spaces are in the path to npm-cache npx doesn't work at all on Windows if spaces are in the path to npm-cache Sep 5, 2019
@AlCalzone
Copy link
Collaborator

I've mentioned this in the README, since the PR doesn't look like it will be merged anytime soon.

@AlCalzone AlCalzone added the external This is not a problem of the creator or the adapter template label Jan 21, 2020
@AlCalzone
Copy link
Collaborator

npm/npx#30 (comment)

Seems we have to wait until at least the 2nd half of 2020

@mrinalpathak16
Copy link

this worked for me -
https://stackoverflow.com/a/46871748/12581294

@AlCalzone
Copy link
Collaborator

Sadly this is nothing we can do in the script. The user has to open the folder in "short mode" before executing create-adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external This is not a problem of the creator or the adapter template
Projects
None yet
Development

No branches or pull requests

3 participants