universal-vue / uvue

Vue CLI plugin to create universal Vue applications with ease
https://universal-vue.github.io/docs/
MIT License
127 stars 13 forks source link

Cannot read property '$meta' of undefined — if src/main.js is renamed #45

Closed Grawl closed 4 years ago

Grawl commented 4 years ago

Describe the bug

I want to rename src/main.js to index.js. But if I change paths.main in uvue.config.js to './src/index.js' I got this error:

 DONE  Compiled successfully in 195ms

 I  Server is running: http://localhost:8528
 I  Type "rs" to restart server
[1583206208615] ERROR (9890 on iMac.local): Cannot read property '$meta' of undefined
    TypeError: Cannot read property '$meta' of undefined
        at __webpack_exports__.default (webpack:///./node_modules/@uvue/core/lib/server.js?:30:18)

To Reproduce

  1. Rename src/main.js to index.js or anything
  2. Add main: './src/index.js' to paths: {} in uvue.config.js
  3. Run vue-cli-service ssr:serve

Additional context

node: 12.15.0
vue-cli: 3.12.1
@uvue/core: 0.1.5
@uvue/server: 0.1.3
os: macOS Catalina 10.15.2 (19C57)
browser: Google Chrome 80.0.3987.122
Grawl commented 4 years ago

Actually, I want to move server/ and plugins/ out of src/ and rename src/ to client/ to separate configurations, backend and frontend code.

yabab-dev commented 4 years ago

Thanks for reporting this, indeed there is a little bug here, it will be fixed soon!

As a workarround, try to not provide the extension of your main file, (.js or .ts), so you can setup your uvue.config.js like this:

export default {
  paths: {
    main: 'index', // Without file extension
  }
};
Grawl commented 4 years ago

Thank you! It's working for me now.

Also, I have to add chain.resolve.alias.set('@', path.resolve(__dirname, 'client')) to chainWebpack() in vue.config.js to rename all src/ folder to client/

yabab-dev commented 4 years ago

Fixed in 0.1.6

robodude666 commented 4 years ago

Piggy backing off of google's top result to hopefully save someone else an hour. I've also ran into this error if I switch module to commonjs in tsconfig.json.