vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.57k stars 4.76k forks source link

Custom component vuepress CLI build error: render function or template not defined in component #844

Closed flacito closed 6 years ago

flacito commented 6 years ago

Bug report

Version

0.14.4

Steps to reproduce

  1. Running npx vuepress dev works fine
  2. Running npx vuepress build results in a compile error for my custom component in the repo below, error is below

https://dev.azure.com/flacito/hello-azure-app-service/_git/hello-azure-vuepress

What is expected?

Success full build with vuepress build (I'm actually running npx vuepress build in the repo build)

What is actually happening?

This is the log from the Azure DevOps build but the same happens on Mac OS 10.13.6

2018-09-16T13:13:11.5584494Z ##[section]Starting: CmdLine
2018-09-16T13:13:11.5717385Z ==============================================================================
2018-09-16T13:13:11.5733273Z Task         : Command Line
2018-09-16T13:13:11.5749176Z Description  : Run a command line script using cmd.exe on Windows and bash on macOS and Linux.
2018-09-16T13:13:11.5766077Z Version      : 2.136.0
2018-09-16T13:13:11.5780681Z Author       : Microsoft Corporation
2018-09-16T13:13:11.5797145Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
2018-09-16T13:13:11.5812205Z ==============================================================================
2018-09-16T13:13:11.8926550Z Generating script.
2018-09-16T13:13:11.9123229Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/14afefc2-5bfb-4807-89fc-62845d33a667.sh
2018-09-16T13:13:34.2134705Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
2018-09-16T13:13:34.2155574Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2018-09-16T13:13:34.2165074Z 
2018-09-16T13:13:34.2185439Z added 1316 packages from 670 contributors and audited 11942 packages in 21.92s
2018-09-16T13:13:34.2204695Z found 0 vulnerabilities
2018-09-16T13:13:34.2212369Z 
2018-09-16T13:13:34.4338746Z 
2018-09-16T13:13:34.4358552Z > hello-azure-vuepress@1.0.0 build /home/vsts/work/1/s
2018-09-16T13:13:34.4377983Z > npx vuepress build
2018-09-16T13:13:34.4386333Z 
2018-09-16T13:13:35.0965321Z 
2018-09-16T13:13:35.0986695Z  WAIT  Extracting site metadata...
2018-09-16T13:13:36.9290071Z [13:13:36] Compiling Client
2018-09-16T13:13:36.9501600Z [13:13:36] Compiling Server
2018-09-16T13:13:36.9549206Z (node:9202) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
2018-09-16T13:13:47.6991729Z [13:13:47] Compiled Server in 11s
2018-09-16T13:13:47.7325880Z [13:13:47] Compiled Client in 11s
2018-09-16T13:13:47.7758145Z  WAIT  Rendering static HTML...
2018-09-16T13:13:47.8533414Z Rendering page: /Rendering page: /seesecret.html FAIL  Error rendering /seesecret.html:
2018-09-16T13:13:47.8551857Z Error: render function or template not defined in component: SeeSecret
2018-09-16T13:13:47.8569742Z     at normalizeRender (/home/vsts/work/1/s/node_modules/vue-server-renderer/build.js:7407:13)
2018-09-16T13:13:47.8588506Z     at renderComponentInner (/home/vsts/work/1/s/node_modules/vue-server-renderer/build.js:7531:3)
2018-09-16T13:13:47.8608429Z     at renderComponent (/home/vsts/work/1/s/node_modules/vue-server-renderer/build.js:7502:5)
2018-09-16T13:13:47.8626759Z     at resolve (/home/vsts/work/1/s/node_modules/vue-server-renderer/build.js:7563:9)
2018-09-16T13:13:47.8642329Z     at <anonymous>
2018-09-16T13:13:48.7646923Z npm ERR! code ELIFECYCLE
2018-09-16T13:13:48.7667066Z npm ERR! errno 1
2018-09-16T13:13:48.7684565Z npm ERR! hello-azure-vuepress@1.0.0 build: `npx vuepress build`
2018-09-16T13:13:48.7731194Z npm ERR! Exit status 1
2018-09-16T13:13:48.7749207Z npm ERR! 
2018-09-16T13:13:48.7766977Z npm ERR! Failed at the hello-azure-vuepress@1.0.0 build script.
2018-09-16T13:13:48.7783583Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-09-16T13:13:51.0483475Z 
2018-09-16T13:13:51.0505396Z npm ERR! A complete log of this run can be found in:
2018-09-16T13:13:51.0523962Z npm ERR!     /home/vsts/.npm/_logs/2018-09-16T13_13_48_767Z-debug.log
2018-09-16T13:13:51.0659746Z ##[error]Bash exited with code '1'.
2018-09-16T13:13:51.1157650Z ##[section]Finishing: CmdLine

Other relevant information

Binaryify commented 6 years ago

use ClientOnly can solve it

ulivz commented 6 years ago

Duplicate of https://github.com/vuejs/vuepress/issues/786, for now you cannot run dev and build at the same time, and this has been addressed at the next version.

flacito commented 6 years ago

I don't have any other projects running with dev. That log I showed you is a CI build. @ulivz I don't think this is a dupe.

QMangoJ commented 5 years ago
QMangoJ commented 5 years ago

use ClientOnly can solve it

QMangoJ commented 5 years ago
ulivz commented 5 years ago

@flacito

See your log:

Error: render function or template not defined in component: SeeSecret

To report an issue that only happens in the scene you are in, the best and direct way is to provide a reproduction repo (e.g. vuepress-issue-example), otherwise I don't know where you are going wrong.

danieleperot commented 5 years ago

For whoever is still in need of help: I did experience the same issue with a component I made. The solution for me was to wrap it in my .md file inside the ClientOnly component:

<!-- Inside my-page.md -->
<ClientOnly>
  <MyComponent />
</ClientOnly

Be very careful not to put more than 2 spaces or a TAB before <MyComponent /> as Markdown will interpret it as a code block (take a look at #1043 for more details).

You can find more info here: https://vuepress.vuejs.org/guide/using-vue.html#browser-api-access-restrictions

Yan2603 commented 3 years ago

m