【问题标题】:Unable to connect Vue app to my local port无法将 Vue 应用程序连接到我的本地端口
【发布时间】:2018-10-08 23:29:08
【问题描述】:

我正在运行 npm run dev 以连接我的应用以在浏览器中查看,但我不断收到此错误:


    > sh:/Users/jasmineanderson/chibi/chibi_hub/client/node_modules/.bin/webpack-dev-server: Permission denied 
    > npm ERR! code ELIFECYCLE 
    > npm ERR! errno 126 
    > npm ERR! chibi_hub@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js` npm ERR! 
    > Exit status 126 npm ERR!  npm ERR!
    > Failed at the chibi_hub@1.0.0 dev script. npm ERR! 
    > This is probably not a problem with npm. There is likely additional logging output
    > above.
    > 
    > npm ERR! A complete log of this run can be found in:   
    > /Users/jasmineanderson/.npm/_logs/2018-10-08T22_43_38_723Z-debug.log

我检查以确保端口 8080 上没有运行其他任何东西,但我仍然收到错误

这是日志:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using npm@6.4.1
3 info using node@v10.9.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle chibi_hub@1.0.0~predev: chibi_hub@1.0.0
6 info lifecycle chibi_hub@1.0.0~dev: chibi_hub@1.0.0
7 verbose lifecycle chibi_hub@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle chibi_hub@1.0.0~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/jasmineanderson/chibi/chibi_hub/client/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands
9 verbose lifecycle chibi_hub@1.0.0~dev: CWD: /Users/jasmineanderson/chibi/chibi_hub/client
10 silly lifecycle chibi_hub@1.0.0~dev: Args: [ '-c',
10 silly lifecycle   'webpack-dev-server --inline --progress --config build/webpack.dev.conf.js' ]
11 silly lifecycle chibi_hub@1.0.0~dev: Returned: code: 126  signal: null
12 info lifecycle chibi_hub@1.0.0~dev: Failed to exec dev script
13 verbose stack Error: chibi_hub@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
13 verbose stack Exit status 126
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:961:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)
14 verbose pkgid chibi_hub@1.0.0
15 verbose cwd /Users/jasmineanderson/chibi/chibi_hub/client
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v10.9.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 126
22 error chibi_hub@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
22 error Exit status 126
23 error Failed at the chibi_hub@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]

我发现问题似乎出在 webpack 上,但我不确定如何解决它。 非常感谢您的帮助!

【问题讨论】:

  • 你有没有机会 sudo 你的 npm install 命令?看起来您有权限错误:/Users/jasmineanderson/chibi/chibi_hub/client/node_modules/.bin/webpack-dev-server: Permission denied 另外,您能否尝试完全删除 node_modules 文件夹并再次运行 npm install 以查看是否解决了吗?
  • 病帖就是答案,希望你不介意这样标记:)

标签: vue.js npm


【解决方案1】:

从 package.json 更改/添加开发服务器端口

【讨论】:

    【解决方案2】:

    权限错误表明所有者可能不是当前用户。 在这种情况下,删除文件夹并在不使用 sudo 的情况下重新安装是正确的答案:)

    【讨论】:

      猜你喜欢
      • 2021-05-03
      • 1970-01-01
      • 1970-01-01
      • 2017-06-28
      • 1970-01-01
      • 2022-09-24
      • 2019-12-15
      • 2012-12-26
      • 2012-06-05
      相关资源
      最近更新 更多