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

vuepress dev: throws res.getHeader() is not a function #1417

Closed
tohagan opened this Issue Mar 8, 2019 · 60 comments

Comments

Projects
None yet
@tohagan
Copy link

tohagan commented Mar 8, 2019

  • I confirm that this is an issue rather than a question.

Bug report

Version

  • vuepress@0.14.10
  • Reproduce same fault with node v10.9.0 AND node v8.11.4
  • Windows 10

Steps to reproduce

NOTE: This was a first time use of vuepress.

$ npm i -g vuepress
$ echo "# Some Stuff" >> README.md
$ vuepress dev

> VuePress dev server listening at http://localhost:8080/

Visit http://localhost:8080/ in browser

Server throws ...

(node:14508) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
    at processRequest (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\webpack-dev-middleware\lib\middleware.js:82:18)
    at ready (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\webpack-dev-middleware\lib\util.js:51:12)
    at handleRequest (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\webpack-dev-middleware\lib\util.js:167:5)
    at Promise (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\webpack-dev-middleware\lib\middleware.js:44:7)
    at new Promise (<anonymous>)
    at middleware (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\webpack-dev-middleware\lib\middleware.js:43:12)
    at Promise.all.Promise (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\koa-webpack\index.js:43:7)
    at new Promise (<anonymous>)
    at C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\koa-webpack\index.js:42:5
    at dispatch (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\koa\node_modules\koa-compose\index.js:42:32)
    at C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\@shellscape\koa-static\legacy\index.js:58:19
    at Generator.throw (<anonymous>)
    at step (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\@shellscape\koa-static\legacy\index.js:6:221)
    at _throw (C:\ProgramData\nvm\v10.9.0\node_modules\vuepress\node_modules\@shellscape\koa-static\legacy\index.js:6:455)
(node:14508) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14508) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@tohagan

This comment has been minimized.

Copy link
Author

tohagan commented Mar 8, 2019

https://github.com/webpack/webpack-dev-middleware/blob/master/lib/middleware.js#L82

        if (!res.getHeader('Content-Type')) {   <<< 
          res.setHeader('Content-Type', contentType);
        }
        res.setHeader('Content-Length', content.length);
@ing670

This comment has been minimized.

Copy link

ing670 commented Mar 8, 2019

how to resolve this problem?

@tohagan

This comment has been minimized.

Copy link
Author

tohagan commented Mar 8, 2019

@ing670 I've never used vuepress before ... but I think the solution for this bug in on the way as part of a fix to koa-webpack that this project depends on. vuepress will need to upgrade once this fix is released. In the meantime an older version of vuepress might work ... I tried several but they all broke so I gave up. Now looking at using https://gridsome.org/ . gidsome had another show stopper but its fixable.

@pata201866

This comment has been minimized.

Copy link

pata201866 commented Mar 8, 2019

got the same problem just now

Version

  • vuepress@0.14.10
  • Reproduce same fault with node v9.0.0 and v8.12.0
  • mac os 10.11.6 and centos 7 (tried it on both os , but failed both )
  • installation : npm install -g vuepress

output below is the centos 7 version


DONE  [11:57:48] Build 636cc5 finished in 23670 ms! 

> VuePress dev server listening at http://localhost:8082/
(node:18856) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
    at processRequest (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/webpack-dev-middleware/lib/middleware.js:82:18)
    at ready (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/webpack-dev-middleware/lib/util.js:51:12)
    at handleRequest (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/webpack-dev-middleware/lib/util.js:167:5)
    at Promise (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/webpack-dev-middleware/lib/middleware.js:44:7)
    at new Promise (<anonymous>)
    at middleware (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/webpack-dev-middleware/lib/middleware.js:43:12)
    at Promise.all.Promise (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/koa-webpack/index.js:43:7)
    at new Promise (<anonymous>)
    at /root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/koa-webpack/index.js:42:5
    at dispatch (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/koa/node_modules/koa-compose/index.js:42:32)
    at /root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/@shellscape/koa-static/legacy/index.js:58:19
    at Generator.throw (<anonymous>)
    at step (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/@shellscape/koa-static/legacy/index.js:6:221)
    at _throw (/root/.nvm/versions/node/v8.12.0/lib/node_modules/vuepress/node_modules/@shellscape/koa-static/legacy/index.js:6:455)
    at <anonymous>
(node:18856) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18856) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


and this is macos version

 DONE  [20:04:45] Build 4211fb finished in 3279 ms! 

> VuePress dev server listening at http://localhost:8080/
(node:23109) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: res.getHeader is not a function
(node:23109) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@Yxliam

This comment has been minimized.

Copy link

Yxliam commented Mar 8, 2019

got the same problem just now
(node:1301) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function

@Shigma Shigma added the 0.x label Mar 8, 2019

@abrahamdio

This comment has been minimized.

Copy link

abrahamdio commented Mar 9, 2019

As a quick and temporary fix you can download 0.x yarn.lock and install dependencies from there.

# root dir of your vuepress project
# replace yarn.lock file / create a new one from the above
rm -rf node_modules
yarn install

Edit: @ulivz has a better solution. See below.

@ulivz

This comment has been minimized.

Copy link
Member

ulivz commented Mar 9, 2019

The dependency chain is webpack-serve -> koa-webpack -> webpack-dev-middleware, and it's caused by the underlying webpack-dev-middleware@3.6.1, so If you're a yarn user you can use resolutions for a temporary fix:

  "resolutions": {
    "webpack-dev-middleware": "3.6.0"
  }

While the npm user can re-install webpack-dev-middleware with a specific version:

npm install webpack-dev-middleware@3.6.0

When webpack-dev-middleware fixes the issue and publishes, the issue can be closed.

@edadams

This comment has been minimized.

Copy link

edadams commented Mar 10, 2019

I'm also experiencing this. This is the first time ever that I've searched a repo and actually found my exact same problem!

I'm sorry for the newbie question, but how do I go about implementing @ulivz's fix?

I installed VuePress the recommended way by typing yarn global add vuepress. I didn't use NPM. Happy to go back and do it that way if I need to.

My question is which file should I edit to add the resolutions mentioned above? I'm not seeing a package.json file be generated in the directory where I ran vuepress dev.

@abrahamdio

This comment has been minimized.

Copy link

abrahamdio commented Mar 10, 2019

@edadams
Sorry if my answer confused you, I didn't have so much time at that point to dig down which dependency is the culprit.

Since @ulivz has found the exact module that caused the issue, you can override that module version in your package.json, you can read more about the yarn's resolution docs here, https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

What you want to do is to edit your package.json file, and add,

  "resolutions": {
    "webpack-dev-middleware": "3.6.0"
  }

And run yarn install again. Hope you got it fixed :)

@edadams

This comment has been minimized.

Copy link

edadams commented Mar 10, 2019

@abrahamdio Thank you! I ended up giving up, I'll just wait for the dependency to get updated. I don't have a package.json file generated anywhere after I install VuePress. (I'm sure it's on me being new and not knowing what I'm doing.) No worries, as I say I'll just wait for a proper fix and give this SSG a try later. :)

@abrahamdio

This comment has been minimized.

Copy link

abrahamdio commented Mar 10, 2019

@abrahamdio Thank you! I ended up giving up, I'll just wait for the dependency to get updated. I don't have a package.json file generated anywhere after I install VuePress. (I'm sure it's on me being new and not knowing what I'm doing.) No worries, as I say I'll just wait for a proper fix and give this SSG a try later. :)

@edadams
Sure no worries! It seems that you might want to follow this guide instead, https://vuepress.vuejs.org/guide/getting-started.html#inside-an-existing-project. (This will create a package.json file in that dir that you can tweak with resolutions).

Feel free to contact me if you need further help with general installation, and we can take it somewhere else since its no longer relevant to this thread anymore.

@fanmucc

This comment has been minimized.

Copy link

fanmucc commented Mar 11, 2019

> VuePress dev server listening at http://localhost:8081/
(node:50091) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
    at processRequest (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/middleware.js:82:18)
    at ready (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/util.js:51:12)
    at handleRequest (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/util.js:167:5)
    at Promise (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/middleware.js:44:7)
    at new Promise (<anonymous>)
    at middleware (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/middleware.js:43:12)
    at Promise.all.Promise (/Users/fanmu/Desktop/Learning_blog/node_modules/koa-webpack/index.js:43:7)
    at new Promise (<anonymous>)
    at /Users/fanmu/Desktop/Learning_blog/node_modules/koa-webpack/index.js:42:5
    at dispatch (/Users/fanmu/Desktop/Learning_blog/node_modules/koa/node_modules/koa-compose/index.js:42:32)
    at /Users/fanmu/Desktop/Learning_blog/node_modules/@shellscape/koa-static/legacy/index.js:58:19
    at Generator.throw (<anonymous>)
    at step (/Users/fanmu/Desktop/Learning_blog/node_modules/@shellscape/koa-static/legacy/index.js:6:221)
    at _throw (/Users/fanmu/Desktop/Learning_blog/node_modules/@shellscape/koa-static/legacy/index.js:6:455)
(node:50091) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:50091) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How to deal with the error

@edadams

This comment has been minimized.

Copy link

edadams commented Mar 11, 2019

@fanmucc

This comment has been minimized.

Copy link

fanmucc commented Mar 11, 2019

> VuePress dev server listening at http://localhost:8081/
(node:50091) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
    at processRequest (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/middleware.js:82:18)
    at ready (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/util.js:51:12)
    at handleRequest (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/util.js:167:5)
    at Promise (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/middleware.js:44:7)
    at new Promise (<anonymous>)
    at middleware (/Users/fanmu/Desktop/Learning_blog/node_modules/webpack-dev-middleware/lib/middleware.js:43:12)
    at Promise.all.Promise (/Users/fanmu/Desktop/Learning_blog/node_modules/koa-webpack/index.js:43:7)
    at new Promise (<anonymous>)
    at /Users/fanmu/Desktop/Learning_blog/node_modules/koa-webpack/index.js:42:5
    at dispatch (/Users/fanmu/Desktop/Learning_blog/node_modules/koa/node_modules/koa-compose/index.js:42:32)
    at /Users/fanmu/Desktop/Learning_blog/node_modules/@shellscape/koa-static/legacy/index.js:58:19
    at Generator.throw (<anonymous>)
    at step (/Users/fanmu/Desktop/Learning_blog/node_modules/@shellscape/koa-static/legacy/index.js:6:221)
    at _throw (/Users/fanmu/Desktop/Learning_blog/node_modules/@shellscape/koa-static/legacy/index.js:6:455)
(node:50091) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:50091) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How to deal with the error

the problem has been solved npm i webpack-dev-middleware@3.6.0

@ekhall

This comment has been minimized.

Copy link

ekhall commented Mar 13, 2019

I'm still getting this with webpack-dev-middleware at 3.6.0
I also had to force weback 4.8.1 in the resolutions as well to silence some dependency complaints. But still not working with same error.

@Morgul

This comment has been minimized.

Copy link

Morgul commented Mar 13, 2019

I can confirm that simply adding this to package.json:

  "webpack-dev-middleware": "3.6.0"
},

and then reinstalling dependencies with yarn install allowed it to work.

@vSanjo

This comment has been minimized.

Copy link

vSanjo commented Mar 14, 2019

I'm still having issues @ekhall is.

package.json

{

...

  "scripts": {
    "start": "vuepress dev"
  },

...

  "dependencies": {
    "vuepress": "^0.14.10",
    "webpack-dev-middleware": "^3.6.0"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.16.0"
  }

}

I've tried npm and yarn, both result in the same issue.

EDIT

I actually got it working

My package.json, as @ulivz recommended, was missing a part.

I did rm -rf node_modules yarn.lock package-lock.json just to be sure, then I did a yarn install with the following package.json.

{

...

  "scripts": {
    "start": "vuepress dev"
  },

...

  "dependencies": {
    "vuepress": "^0.14.10"
  },
  "resolutions": {
    "webpack-dev-middleware": "3.6.0"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.16.0"
  }

}

Then you'll run it locally (as the resolution is only installed locally) with a script tag dev: vuepress dev.

rmjordas added a commit to rmjordas/awesome-vue that referenced this issue Mar 14, 2019

Update package manifest
Bumps the vuepress dependency to version 0.14.10 to fix the missing
sidebar btton on a mobile homepage issue. This version introduces a bug
when running the development server but is temporarily fixed by adding
webpack-dev-middleware@3.6.0 as a devDependency.

See:
- vuejs/vuepress#1355
- vuejs/vuepress#1417
@HonmaMeikodesu

This comment has been minimized.

Copy link

HonmaMeikodesu commented Mar 14, 2019

I tried to remove node_modules ,add webpack-dev-middleware@3.6.0 to my package.json and reinstall all dependencies with npm,but ended up with the same error.Then I turn to yarn and finally get it work.So for those who are still struggling with this error,it is strongly recommended to give yarn a try

@rafaeltaro

This comment has been minimized.

Copy link

rafaeltaro commented Mar 14, 2019

removed vuepress using npm uninstall -g vuepress, installed it using yarn.
put dependencies, resolitions and devDependencies on the package...

but still getting the same problem....

Its getting the webpack-dev-middleware from AppData still should i do anything else to use the one from the node_modules of the project folder?

 DONE  [08:53:57] Build 9aff89 finished in 396 ms! (http://localhost:8080/Eguru/wiki/)
(node:13824) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
    at processRequest (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\webpack-dev-middleware\lib\middleware.js:82:18)
    at ready (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\webpack-dev-middleware\lib\util.js:51:12)
    at handleRequest (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\webpack-dev-middleware\lib\util.js:167:5)
    at Promise (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\webpack-dev-middleware\lib\middleware.js:44:7)
    at new Promise (<anonymous>)
    at middleware (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\webpack-dev-middleware\lib\middleware.js:43:12)
    at Promise.all.Promise (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\koa-webpack\index.js:43:7)
    at new Promise (<anonymous>)
    at C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\koa-webpack\index.js:42:5
    at dispatch (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\koa\node_modules\koa-compose\index.js:42:32)
    at C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\@shellscape\koa-static\legacy\index.js:58:19
    at Generator.throw (<anonymous>)
    at step (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\@shellscape\koa-static\legacy\index.js:6:221)
    at _throw (C:\Users\rafae\AppData\Local\Yarn\Data\global\node_modules\@shellscape\koa-static\legacy\index.js:6:455)
(node:13824) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13824) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

EDIT

Got it running using yarn docs:dev instead of vuepress dev
but now im getting a
404
How did we get here?
Take me home.

should i reconfigure something to run using yarn?

luigiwerzowa pushed a commit to Jsparrow/dashboard that referenced this issue Mar 14, 2019

@ekhall

This comment has been minimized.

Copy link

ekhall commented Mar 14, 2019

I was able to fix this as per @Morgul 's description above however it was important to note that I needed to run the local copy of vuepress via the yarn scripts on the installation page (yarn docs:dev, etc) and not via the global vuepress installation.

@easonjim

This comment has been minimized.

Copy link

easonjim commented Mar 15, 2019

I'm working at:
1、create package.json and don’t use global vuepress cli
2、install webpack-dev-middleware@3.6.0 in project
3、npm run docs:dev is working
ex:

{
  "name": "testvuepress",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "vuepress": "^0.14.10"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.16.0",
    "webpack-dev-middleware": "^3.6.0"
  }
}
@bnb

This comment has been minimized.

Copy link

bnb commented Mar 15, 2019

Also getting this problem with a fresh install of the global CLI (via npm) running vuepress dev in a directory with a single Markdown file.

@abrahamdio

This comment has been minimized.

Copy link

abrahamdio commented Mar 15, 2019

@bnb
Based on previous answers, (you could read for more details)

Assuming you're using yarn, add this to your package.json,

"resolutions": {
    "webpack-dev-middleware": "3.6.0"
  },
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }

and yarn install again. Run via yarn docs:dev or yarn docs:build.

If you're using npm,
Run npm install webpack-dev-middleware@3.6.0 --save-dev in your local project folder.
Add this to your package.json,

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }

and run npm run docs:dev or npm run docs:build.

These solutions will install a new local dependency of webpack-dev-middleware@3.6.0, and before someone fixed the real root cause, you should be running with your package manager yarn docs:dev / npm run docs:dev, as this will use your local vuepress instead your global's vuepress.

@AlexZhong22c

This comment has been minimized.

Copy link

AlexZhong22c commented Mar 20, 2019

I find the solution in segmentfault.com. It's about the permission of my Macos.

macos 10.12.6;node 8;you may try this:

npm install -D webpack-dev-middleware@3.6.0
sudo npm run docs:dev

Hope that can help you.

@mattcotter

This comment has been minimized.

Copy link

mattcotter commented Mar 20, 2019

So for those of you having issues still with the fixes listed above, a team mate of mine figured out that the issue was having Vuepress installed globally. It appears that the fixes above are only applying to your local project directory and is not being applied to the global installation.

Following these instructions, I was able to get it to finally work:

  1. npm uninstall -g vuepress
  2. Run npm install webpack-dev-middleware@3.6.0 to install locally
  3. add "vuepress:dev": "vuepress dev" to your package.json file
  4. npm run vuepress:dev

You may want to add the resolutions code from above to your package.json as well but I was able to get it to run without: "resolutions": { "webpack-dev-middleware": "3.6.0" }

NamPNQ added a commit to NamPNQ/vapid that referenced this issue Mar 21, 2019

Update package.json.ejs
Fix res.getHeader is not function
Ref: vuejs/vuepress#1417
@bnb

This comment has been minimized.

Copy link

bnb commented Mar 23, 2019

Can a temporary solution for the globally installed VuePress be to published a version with a pinned webpack-dev-middleware@3.6.0?

ulivz added a commit to ulivz/koa-webpack that referenced this issue Mar 24, 2019

@Mr-wang007s

This comment has been minimized.

Copy link

Mr-wang007s commented Mar 25, 2019

采坑+1

(node:14088) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function

解决方法: 删除 node_modules, 使用yarn 重新安装依赖。

package.json
{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  },
  "devDependencies": {
    "vuepress": "^0.14.10",
    "webpack-dev-middleware": "3.6.0"
  },
    "resolutions": {
    "webpack-dev-middleware": "3.6.0"
  }
}
@yxbysxcoco

This comment has been minimized.

Copy link

yxbysxcoco commented Mar 26, 2019

why don't use 1.x ?
all these solutions I had tried but also made issues

@howar31

This comment has been minimized.

Copy link

howar31 commented Mar 26, 2019

why don't use 1.x ?
all these solutions I had tried but also made issues

因為 1.x 目前還在 Alpha 階段,配置可能會不斷修改,為了避免重複修改用穩定版可能比較好 roadmap 說 1.x 預計六月釋出,現在算穩定了嗎?如果足夠成熟我也想盡快升級到 1.x

Since 1.x is still in Alpha now, the features might change in the near future. I preferred to use stable release instead.
According to roadmap, 1.x should be released on this June. I wanna know if 1.x is stable enough right now? I'd like to upgrade to 1.x as soon as possible.

@uniquejava

This comment has been minimized.

Copy link

uniquejava commented Mar 26, 2019

一直听闻vuepress. 今天决定试玩一下, hello world跑不成功, google至此,期待尽快解决。

My first try of vuepress redirected me here (手动滑稽)

@yxbysxcoco

This comment has been minimized.

Copy link

yxbysxcoco commented Mar 28, 2019

why don't use 1.x ?
all these solutions I had tried but also made issues

因為 1.x 目前還在 Alpha 階段,配置可能會不斷修改,為了避免重複修改用穩定版可能比較好 roadmap 說 1.x 預計六月釋出,現在算穩定了嗎?如果足夠成熟我也想盡快升級到 1.x

Since 1.x is still in Alpha now, the features might change in the near future. I preferred to use stable release instead.
According to roadmap, 1.x should be released on this June. I wanna know if 1.x is stable enough right now? I'd like to upgrade to 1.x as soon as possible.

I have been using it now.And feeling very stable.

@howar31

This comment has been minimized.

Copy link

howar31 commented Mar 28, 2019

why don't use 1.x ?
all these solutions I had tried but also made issues

因為 1.x 目前還在 Alpha 階段,配置可能會不斷修改,為了避免重複修改用穩定版可能比較好 roadmap 說 1.x 預計六月釋出,現在算穩定了嗎?如果足夠成熟我也想盡快升級到 1.x
Since 1.x is still in Alpha now, the features might change in the near future. I preferred to use stable release instead.
According to roadmap, 1.x should be released on this June. I wanna know if 1.x is stable enough right now? I'd like to upgrade to 1.x as soon as possible.

I have been using it now.And feeling very stable.

Wow cool! I'll take a shot. Thanks

kazupon added a commit to kazupon/vue-i18n that referenced this issue Mar 28, 2019

📌 dependency: add resolutions
NOTE:
  workaround of vuepress issue: vuejs/vuepress#1417
@gotophp

This comment has been minimized.

Copy link

gotophp commented Mar 30, 2019

mac 10.13.6
npm install -D webpack-dev-middleware@3.6.0

@jackmahoney

This comment has been minimized.

Copy link

jackmahoney commented Mar 30, 2019

Is vuepress still actively maintained? would love to help if not

@LinusBorg

This comment has been minimized.

Copy link
Member

LinusBorg commented Mar 30, 2019

That's a weird question. What would give you the impression it isn't? In the last 17 days over 25 PRs were merged. There's commits like every other day.

https://github.com/vuejs/vuepress/commits/master

@fredia

This comment has been minimized.

Copy link

fredia commented Mar 31, 2019

env:ubuntu 18.04 LTS
if you have run npm install -g vuepress, vuepress will be installed at /usr/local/lib/node_modules/vuepress/node_modules/webpack-dev-middleware, replace webpack-dev-middleware by _webpack-dev-middleware@3.6.0@webpack-dev-middleware

sudo rm -rf /usr/local/lib/node_modules/vuepress/node_modules/webpack-dev-middleware

and then:

sudo cp -r_webpack-dev-middleware@3.6.0@webpack-dev-middleware /usr/local/lib/node_modules/vuepress/node_modules/webpack-dev-middleware

xuhongbo added a commit to xuhongbo/vue-i18n that referenced this issue Apr 1, 2019

同步源仓库代码到本地仓库 (#4)
* 📌 dependency: add resolutions

NOTE:
  workaround of vuepress issue: vuejs/vuepress#1417

* 📦 build(vuepress): generate docs

* 📦 build(dist): generate dist files

* 🎉 release(minor): v8.10.0

* 📝 docs(vuepress): update scoped style docs (kazupon#546) by @kenanchristian

* 📝 docs(vuepress): fix typo in i18n-n functional component (kazupon#549) by @blowsie
@SteakdeNiche

This comment has been minimized.

Copy link

SteakdeNiche commented Apr 1, 2019

mac 10.13.6
npm install -D webpack-dev-middleware@3.6.0

I've done the same on Windows: in a basic yarn installation, go to 'C:\Users\Username\AppData\Local\Yarn\Data\global\node_modules' and just run:
npm install -D webpack-dev-middleware@3.6.0 to force the webpack-dev-middleware version.

@panda8z

This comment has been minimized.

Copy link

panda8z commented Apr 2, 2019

I'm still having issues @ekhall is.

package.json

{

...

  "scripts": {
    "start": "vuepress dev"
  },

...

  "dependencies": {
    "vuepress": "^0.14.10",
    "webpack-dev-middleware": "^3.6.0"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.16.0"
  }

}

I've tried npm and yarn, both result in the same issue.

EDIT

I actually got it working

My package.json, as @ulivz recommended, was missing a part.

I did rm -rf node_modules yarn.lock package-lock.json just to be sure, then I did a yarn install with the following package.json.

{

...

  "scripts": {
    "start": "vuepress dev"
  },

...

  "dependencies": {
    "vuepress": "^0.14.10"
  },
  "resolutions": {
    "webpack-dev-middleware": "3.6.0"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.16.0"
  }

}

Then you'll run it locally (as the resolution is only installed locally) with a script tag dev: vuepress dev.

thank U for solved my problem

MacOS: 10.14.4
node:v10.15.3
npm:6.4.1
vuepress: 0.14.10

@chengpeiquan

This comment has been minimized.

Copy link

chengpeiquan commented Apr 2, 2019

I'm working at:
1、create package.json and don’t use global vuepress cli
2、install webpack-dev-middleware@3.6.0 in project
3、npm run docs:dev is working
ex:

{
  "name": "testvuepress",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "vuepress": "^0.14.10"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.16.0",
    "webpack-dev-middleware": "^3.6.0"
  }
}

Thank you very much!
I user this method by "don’t use global vuepress cli",successfully solved this problem!

@ulivz

This comment has been minimized.

Copy link
Member

ulivz commented Apr 3, 2019

Fixed at webpack/webpack-dev-middleware@56dc705 and released at webpack-dev-middleware@v3.6.2.

For now you can remove all of your hacking, just rm -rf node_modules and run npm install / yarn.

@ulivz ulivz closed this Apr 3, 2019

JasonShin added a commit to machinelearnjs/machinelearnjs that referenced this issue Apr 4, 2019

@AlexZhong22c

This comment has been minimized.

Copy link

AlexZhong22c commented Apr 5, 2019

notice the version of webpack-dev-server

npm install -D webpack-dev-middleware@3.6.2

remove all of hacking, just rm -rf node_modules and run npm install / yarn

And I still fail.Then I update webpack-dev-server,which in the relation that requires the webpack-dev-middleware.And success,I hope that help others.

@akbq2008

This comment has been minimized.

Copy link

akbq2008 commented Apr 18, 2019

I ' m working at
1.rm -rf node_modules and then yarn

yarn add  webpack-dev-middleware@3.6.0
  1. don't use global vuepress cli
yarn add -D vuepress

3.add resolutions to your package.json file

"resolutions": {
    "webpack-dev-middleware": "3.6.0"
  }

my package.json file(I used to use vuepress 1.0 but it didn't work and now I use vuepress 0.14.11)

{
    "scripts": {
        "docs:dev": "vuepress dev docs",
        "docs:build": "vuepress build docs",
        "deploy": "bash deploy.sh"
    },
    "dependencies": {
        "element-ui": "^2.6.1",
        "node-sass": "^4.11.0",
        "sass-loader": "^7.1.0",
        "tudousi_mixins": "^1.0.0",
        "webpack-dev-middleware": "3.6.0"
    },
    "resolutions": {
        "webpack-dev-middleware": "3.6.0"
    },
    "devDependencies": {
        "vuepress": "^0.14.11"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.