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

Build error when import SFC from dependency. #666

Closed
nikhilkul opened this issue Jul 24, 2018 · 3 comments
Closed

Build error when import SFC from dependency. #666

nikhilkul opened this issue Jul 24, 2018 · 3 comments
Labels
has workaround Has a workaround

Comments

@nikhilkul
Copy link

Bug report

Version

0.12.0

Steps to reproduce

  1. Clone reproduction repo
  2. yarn install
  3. yarn global add vuepress
  4. yarn docs:build -> Fails with
╰─$ yarn docs:build                                                      130 ↵
yarn run v1.7.0
$ vuepress build docs

 WAIT  Extracting site metadata...
<product2></product2>
[4:51:09 PM] Compiling Client
[4:51:09 PM] Compiling Server
(node:17386) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
<product2></product2>
[4:51:14 PM] Compiled Server in 5s
[4:51:16 PM] Compiled Client in 7s
 WAIT  Rendering static HTML...
Rendering page: / FAIL  Error rendering /:
Error: render function or template not defined in component: product2
    at normalizeRender (/Users/z00335s/gitdir/vuepress-test/node_modules/vue-server-renderer/build.js:7396:13)
    at renderComponentInner (/Users/z00335s/gitdir/vuepress-test/node_modules/vue-server-renderer/build.js:7520:3)
    at renderComponent (/Users/z00335s/gitdir/vuepress-test/node_modules/vue-server-renderer/build.js:7491:5)
    at resolve (/Users/z00335s/gitdir/vuepress-test/node_modules/vue-server-renderer/build.js:7552:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What is expected?

yarn docs:build should not fail if yarn docs:dev is not throwing any error.

What is actually happening?

When I remove following imports, in docs/.vuepress/components/product2.vue the build works.

import DatePicker from "vue2-datepicker";
Vue.component('DatePicker', DatePicker)

Other relevant information

  • Your OS: MacOs Sierra 10.12.6
  • Node.js version: 10.7
  • Browser version: No need
  • Is this a global or local install? : Global
  • Which package manager did you use for the install? : Yarn
@ulivz ulivz changed the title Error: render function or template not defined in component: Build error when import component from dependency. Jul 25, 2018
@ulivz ulivz changed the title Build error when import component from dependency. Build error when import SFC from dependency. Jul 25, 2018
@ulivz ulivz added duplicate has workaround Has a workaround labels Jul 25, 2018
@ulivz
Copy link
Member

ulivz commented Jul 25, 2018

Duplicate of #451, please step over there to see the workaround.

@ulivz ulivz closed this as completed Jul 25, 2018
@nikhilkul
Copy link
Author

nikhilkul commented Jul 27, 2018

@ulivz #451 says add code to lib/app/app.js.
Does that mean I have to create a new .js file somewhere? Tried docs/.vuepress/enhanceApp.js as was mentioned in #443 , but it throws ReferenceError: window is not defined

Simply changing import DatePicker from 'vue2-datepicker'; to import DatePicker from '../../../node_modules/vue2-datepicker; in the reproduction repository mentioned above does not solve the issue.
The library that I am trying to import, does not have a .vue file at root path.
The folder structure looks like this,

node_modules/vue2-datepicker
├── CHANGELOG.md
├── LICENSE
├── README.md
├── README.zh-CN.md
├── lib
│   ├── datepicker.css
│   ├── datepicker.js
│   └── index.js
├── package.json
└── src
    ├── calendar.vue
    ├── directives
    │   └── clickoutside.js
    ├── index.js
    ├── index.scss
    ├── index.vue
    ├── locale
    │   └── languages.js
    ├── mixins
    │   └── locale.js
    ├── panel
    │   ├── date.js
    │   ├── month.js
    │   ├── time.js
    │   └── year.js
    └── utils
        ├── index.js
        └── scroll-into-view.js

I tried following:

  1. import DatePicker from '../../../node_modules/vue2-datepicker/src/index.vue;
  2. import DatePicker from '../../../node_modules/vue2-datepicker

Both didn't work.

@nikhilkul
Copy link
Author

@ulivz Can you please help me for this ⏫

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has workaround Has a workaround
Projects
None yet
Development

No branches or pull requests

2 participants