vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.32k forks source link

unable to use port under 1024 , npm version is 8.1.2 #6894

Open MirrorXu opened 2 years ago

MirrorXu commented 2 years ago

Version

4.5.15

Reproduction link

github.com/MirrorXu/vue-demo

Environment info

  System:
    OS: macOS 12.1
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 16.13.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 8.1.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Edge: Not Found
    Firefox: Not Found
    Safari: 15.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1 
    @vue/babel-helper-vue-transform-on:  1.0.2 
    @vue/babel-plugin-jsx:  1.1.1 
    @vue/babel-plugin-transform-vue-jsx:  1.2.1 
    @vue/babel-preset-app:  4.5.15 
    @vue/babel-preset-jsx:  1.2.4 
    @vue/babel-sugar-composition-api-inject-h:  1.2.1 
    @vue/babel-sugar-composition-api-render-instance:  1.2.4 
    @vue/babel-sugar-functional-vue:  1.2.2 
    @vue/babel-sugar-inject-h:  1.2.2 
    @vue/babel-sugar-v-model:  1.2.3 
    @vue/babel-sugar-v-on:  1.2.3 
    @vue/cli-overlay:  4.5.15 
    @vue/cli-plugin-babel: ~4.5.0 => 4.5.15 
    @vue/cli-plugin-eslint: ~4.5.0 => 4.5.15 
    @vue/cli-plugin-router: ~4.5.0 => 4.5.15 
    @vue/cli-plugin-vuex: ~4.5.0 => 4.5.15 
    @vue/cli-service: ~4.5.0 => 4.5.15 
    @vue/cli-shared-utils:  4.5.15 
    @vue/component-compiler-utils:  3.3.0 
    @vue/preload-webpack-plugin:  1.1.2 
    @vue/web-component-wrapper:  1.3.0 
    eslint-plugin-vue: ^6.2.2 => 6.2.2 
    vue: ^2.6.11 => 2.6.14 
    vue-awesome-swiper: ^3.1.3 => 3.1.3 
    vue-cropper: ^0.4.9 => 0.4.9 
    vue-eslint-parser:  7.11.0 
    vue-hot-reload-api:  2.3.4 
    vue-lazyload:  1.2.3 
    vue-loader:  13.7.3 (15.9.8, 16.8.3)
    vue-photo-preview: ^1.1.3 => 1.1.3 
    vue-qr: ^2.3.0 => 2.5.0 
    vue-router: ^3.2.0 => 3.5.3 
    vue-style-loader:  3.1.2 (4.1.3)
    vue-template-compiler: ^2.6.11 => 2.6.14 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^3.4.0 => 3.6.2 
  npmGlobalPackages:
    @vue/cli: 4.5.15

Steps to reproduce

  1. create vue.config.js and specify the devServer

    devServer: {
    port: 80
    },
    
  2. sudo npm run serve

  3. the vue App not serve at port 80 , but 1024 , Terninal info: App running at:

What is expected?

i expected specify the port under 1024 at npm@8+

What is actually happening?

can not specify the port under 1024 at npm@8+ macos


The problem is at npm@8.1.2 。 when i use npm@6 , It becomes normal 。

ghost commented 2 years ago

Normally, to run a program that bind to port less than 1024, it needs to be run as sudo.

https://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html

KOR-Believer commented 2 years ago

Normally, to run a program that bind to port less than 1024, it needs to be run as sudo.

https://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html

Even using sudo doesn't help. The problematic nodejs version is 15 or higher.

mima3 commented 2 years ago

"sudo npm run" is changed between npm v6 and v7.

But the following commands can be used.

sudo node_modules/.bin/vue-cli-service serve
wakefun commented 1 year ago

But the following commands can be used.

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

really worked! Thank you for sharing it.