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

vsce package error on Windows: The filename, directory name, or volume label syntax is incorrect. #747

Closed
devhawk opened this issue Jun 25, 2022 · 18 comments

Comments

@devhawk
Copy link

devhawk commented Jun 25, 2022

I created a new VSCode extension with yo code (used testext as the extension name, chose defaults for other options), changed to the new extension directory and ran vsce package and it failed.

$ vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> testext@0.0.1 vscode:prepublish
> npm run compile

The filename, directory name, or volume label syntax is incorrect.
 ERROR  npm failed with exit code 1

I am able to vsce package on WSL Ubuntu 20.04.

node --version: v16.15.1
npm --version: 8.13.1
vsce --version: 2.9.2

@devhawk
Copy link
Author

devhawk commented Jun 25, 2022

FYI, I am able to run vsce package on another Windows machine, so this is clearly a local config issue. However, I have no idea how to troubleshoot this.

@Zxynine
Copy link

Zxynine commented Jun 26, 2022

I am in a similar boat, I keep getting brought back to this page as its the only relevant reference to this problem.

@Zxynine
Copy link

Zxynine commented Jun 26, 2022

After a long time of trying everything, removing the line :"vscode:prepublish": "npm run compile", from scripts in package.json allowed me to finally run vsce package, it clearly is NOT ideal but I also dont know why it would even cause a problem. I can run npm run compile perfectly fine and all of the debug runs work.

@devhawk
Copy link
Author

devhawk commented Jun 26, 2022

After a long time of trying everything, removing the line :"vscode:prepublish": "npm run compile", from scripts in package.json allowed me to finally run vsce package, it clearly is NOT ideal but I also dont know why it would even cause a problem. I can run npm run compile perfectly fine and all of the debug runs work.

I see similar behavior. I can run npm run compile directly, but if I try and run npm run vscode:prepublish (which just invokes npm run compile), it crashes

@ied206
Copy link

ied206 commented Jun 26, 2022

I have the same issue with my local development machine.

FYI, I am able to run vsce package on another Windows machine, so this is clearly a local config issue. However, I have no idea how to troubleshoot this.

It works on the other local system, too.

The strange thing is, npm run compile command itself succeeds when I type it myself.

 "scripts": {
        "vscode:prepublish": "npm run compile",
        "compile": "tsc -p ./",
        "watch": "tsc -watch -p ./",
        "pretest": "npm run compile && npm run lint",
        "lint": "eslint src --ext ts",
        "test": "node ./out/test/runTest.js"
    },
  • System Information
Command Version
node --version v18.4.0
npm --version 8.13.1
vsce --version 2.9.2

I have tested and reproduced the issue on cmd and PowerShell core both.

@sinotaotao
Copy link

I think the problem just happens on windows system, the colon : in script name let commandline parser treat it as volume letter, then refuse to execute the right scripts.

@sinotaotao
Copy link

There is a simple solution: change package script to: npm run build && vsce package
or webpack --mode production && vsce package if you use bundle tool. AND remove the old vscode:prepublish script.

Consider rename vscode:prepublish to vscode-prepublish avoid problems on windows platform?

@joaomoreno
Copy link
Member

All of this is very strange:

  • We haven't released a new version of vsce recently which would break this
  • 4 different people talked in this issue within ~24h
  • I'm on Windows and I can't repro (node 16.15.1, npm 8.11.0, vsce 2.9.2)

What's common between all of you?

@joaomoreno
Copy link
Member

Figured it out: I can repro if I update npm to 8.13.1. This is a bug in npm.

@joaomoreno
Copy link
Member

joaomoreno commented Jun 26, 2022

Upstream issue, npm will fix: npm/cli#5066

Current workaround: downgrade npm to 8.11.0

@joaomoreno joaomoreno closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2022
@ied206
Copy link

ied206 commented Jun 26, 2022

My machine has npm 8.13.1 installed, and it still fails to run vsce publish with The filename, directory name, or volume label syntax is incorrect message.

image

@joaomoreno
Copy link
Member

Please downgrade npm.

@sinotaotao
Copy link

sinotaotao commented Jun 27, 2022

Thanks @joaomoreno , run npm i -g npm@8.11.0 and wait npm team to fix it. everyone!

@devhawk
Copy link
Author

devhawk commented Jun 27, 2022

npm i -g npm@8.13.0

Confirmed downgrading npm resolves the issue on my machine. I'm using npm-windows-upgrade so I ran npm-windows-upgrade -v 8.11.0 in an admin terminal window.

@Zxynine
Copy link

Zxynine commented Jun 27, 2022

I tried to downgrade and it caused more problems than I knew how to handle, I reverted and just used "vscode-prepublish" as @sinotaotao suggested and everything works fine.

@sinotaotao
Copy link

sinotaotao commented Jun 28, 2022

@Zxynine pay attention to this, rename vscode:prepublish to vscode-prepublish bypassed the prepublish task. Current implementation just execute vscode:prepublish script.
The renaming is a suggestion to MS

@Jason3S
Copy link

Jason3S commented Jun 28, 2022

Thanks @joaomoreno , run npm i -g npm@8.13.0 and wait npm team to fix it. everyone!

The bug is also in 8.13.0.

@joaomoreno
Copy link
Member

I've edited @sinotaotao's post so it doesn't confuse anyone else.

Workaround: npm i -g npm@8.11.0

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

6 participants