0

我正在按照教程https://mindthecode.com/using-vue-components-in-your-express-app/将 vue 组件与 Express 一起使用。

其中一部分是配置一个 npm dev 脚本以使用 Browserify/vueify 编译 vue 组件,启动 Watchify,然后启动 Express Server。

教程的每一步都有效,但“开发”脚本不能 100% 工作,因为快速服务器没有启动。

任何人都可以帮助弄清楚出了什么问题或我需要做什么才能使该脚本正常工作吗?

包.json

"scripts": {
    "start": "echo 'server starting on port 3000' & node ./bin/www",    
    "dev": "watchify -vd -p browserify-hmr -t vueify -e public/javascripts/main.js -o public/javascripts/bundle.js & node ./bin/www"
  },

'npm run dev' 编译 vue 组件并启动 watchify,如果我更改 vue 组件代码,热重载将起作用。但是,快递服务器无法启动?

笔记:

browserify -t vueify -e public/javascripts/main.js -o public/javascripts/bundle.js – works fine at the command line to compile the .vue files

npm start – works fine and can load page at ‘localhost:3000’

我正在使用 windows10、node v8.9.4 和 package.json 中的一些相关依赖项

"browserify-hmr": "^0.3.5",
"express": "~4.14.0",
"vue": "^2.5.0",
"vueify": "^9.4.1",
"watchify": "^3.9.0"
4

1 回答 1

0

您可以从本教程中看到完整的 package.json 和完整的 repo

https://github.com/Hyra/vue-components-in-express/blob/master/package.json

{
  "name": "vue-components-in-express",
  "version": "0.0.1",
  "private": false,
  "description": "Sample code to support blog post 'Using Vue Components in your Express app' at https://mindthecode.com/using-vue-components-in-your-express-app/",
  "author": "Stef van den Ham <stef@mindthecode.com>",
  "scripts": {
    "start": "node ./bin/www",
    "dev": "watchify -vd -p browserify-hmr -t vueify -e public/javascripts/main.js -o public/javascripts/bundle.js & node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.15.2",
    "browserify-hmr": "^0.3.5",
    "cookie-parser": "~1.4.3",
    "debug": "~2.2.0",
    "express": "~4.14.0",
    "morgan": "~1.7.0",
    "node-sass": "^4.5.3",
    "pug": "~2.0.0-beta6",
    "serve-favicon": "~2.3.0",
    "vue": "^2.5.0",
    "vueify": "^9.4.1",
    "watchify": "^3.9.0"
  }
}
于 2018-05-23T14:35:41.167 回答