Vue-cli: [WSL] Error: spawn cmd.exe ENOENT

Created on 9 Jun 2019  路  4Comments  路  Source: vuejs/vue-cli

Version

3.5.3

Reproduction link

https://github.com/PanJiaChen/vue-element-admin

Environment info

Win10 Sub Linux ( Ubuntu )

Steps to reproduce

yarn install

./node_modules/.bin/vue-cli-service serve

What is expected?

without error

What is actually happening?

$ ./node_modules/.bin/vue-cli-service serve

events.js:183
throw er; // Unhandled 'error' event
^

Error: spawn cmd.exe ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

needs team repro

Most helpful comment

I think this error is related to this create-react-app issue which is caused by the way the browser is launched in WSL (using cmd.exe which is not in the PATH). The root problem may be in the opn aka open npm package.

A workaround is to add /mnt/c/Windows/System32 to your path before running the command.

e.g.:

PATH="$PATH:/mnt/c/Windows/System32"   /node_modules/.bin/vue-cli-service serve

or

export PATH="$PATH:/mnt/c/Windows/System32"
/node_modules/.bin/vue-cli-service serve

The former command will not alter your current shell while the latter will, so choose the one that suits your needs best.

All 4 comments

Info: WSL 琚敊褰撴垚 Windows

WSL Mistaken for Windows

Is your WSL environment based on Debian? I鈥檝e noticed some strange behaviours with npm in Debian Buster that I鈥檝e not been able to reproduce with the official nodejs binaries and updated versions of npm (node is v10.15.2 and npm 5.8.0 in Debian Buster). Among those were hanging npm ci commands in GitLab runners with docker and the yarn error you鈥檝e got when I executed vue create foo.

I think this error is related to this create-react-app issue which is caused by the way the browser is launched in WSL (using cmd.exe which is not in the PATH). The root problem may be in the opn aka open npm package.

A workaround is to add /mnt/c/Windows/System32 to your path before running the command.

e.g.:

PATH="$PATH:/mnt/c/Windows/System32"   /node_modules/.bin/vue-cli-service serve

or

export PATH="$PATH:/mnt/c/Windows/System32"
/node_modules/.bin/vue-cli-service serve

The former command will not alter your current shell while the latter will, so choose the one that suits your needs best.

Disable browser auto-opening by edit vue.config.js,

module.exports = {
  //...
  devServer: {
    open: false
  }
};

see also https://webpack.js.org/configuration/dev-server/#devserveropen

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JIANGYUJING1995 picture JIANGYUJING1995  路  3Comments

chasegiunta picture chasegiunta  路  3Comments

DrSensor picture DrSensor  路  3Comments

csakis picture csakis  路  3Comments

BusyHe picture BusyHe  路  3Comments