Git Product home page Git Product logo

Comments (22)

Kematia avatar Kematia commented on May 25, 2024 7

If you're on Netlify try adding a .nvmrc file with your desired node version, this fixed it for me!

image

from vue-demi.

antfu avatar antfu commented on May 25, 2024 4

Landed a fix, please try to upgrade the latest @vue/composition-api plugin and try again

from vue-demi.

TonyPythoneer avatar TonyPythoneer commented on May 25, 2024 4

Hi @antfu @Ricklin90085

Before this PR nuxt-community/composition-api#517 gets merged, I have another workaround to this issue.
It's worked to me.

import { resolve } from 'path'
const vueCompositiobnAPIFullpath = resolve("./node_modules/@vue/composition-api/dist/vue-composition-api.esm.js");

config = {
  alias: {
    // keep default settings
    '~~': resolve(__dirname, './'),
    '@@': resolve(__dirname, './'),
    '~': resolve(__dirname, './'),
    '@': resolve(__dirname, './'),
    'assets': resolve(__dirname, './assets'), // (unless you have set a custom `dir.assets`)
    'static': resolve(__dirname, './static'), // (unless you have set a custom `dir.static`)
    // workaround
    '@vue/composition-api/dist/vue-composition-api.esm.js': vueCompositiobnAPIFullpath,
  },
}

Thanks to the @antfu 's answer, he inspires me to have this workaround.


So, when we have this workaround, we can enjoy @vueuse 's charm. :D

from vue-demi.

TonyPythoneer avatar TonyPythoneer commented on May 25, 2024 3

I try to output the source code

(from: https://github.com/nuxt-community/composition-api/blob/1b07abeada072da79c1f0105d73389b799f4f8e1/src/module/index.ts#L29)

  nuxtOptions.alias['@vue/composition-api'] =
    nuxtOptions.alias['@vue/composition-api'] ||
    this.nuxt.resolver.resolveModule(
      '@vue/composition-api/dist/vue-composition-api.esm.js'
    )

The output is like below:

nuxtOptions.alias['@vue/composition-api'] // undefined
this.nuxt.resolver.resolveModule(
 '@vue/composition-api/dist/vue-composition-api.esm.js'
) // /home/tony/tony/bdff-mainsite/node_modules/@vue/composition-api/dist/vue-composition-api.esm.js

Maybe, we can use alias to guide the internal function of @nuxtjs/composition-api to do what we expect.

But I'm not familiar with the relationship between @vue/composition-api/dist/vue-composition-api.esm.js and ./node_modules/vue-demi/lib/index.mjs. Or, who knows the correct import definition to have a workaround?

from vue-demi.

danielroe avatar danielroe commented on May 25, 2024 3

Should be fixed in v0.25.0 ❤️ - let me know if not.

from vue-demi.

antfu avatar antfu commented on May 25, 2024 2

I try to find the source code from the @nuxtjs/composition-api
nuxt-community/composition-api@1b07abe/src/module/index.ts#L29

@TonyPythoneer That's useful, thanks!

/cc @danielroe or do you think we could have one more alias like (I guess the alias is overkilled by replacing the submodules)

 nuxtOptions.alias['@vue/composition-api/dist/vue-composition-api.esm.js'] = 
   this.nuxt.resolver.resolveModule(
     '@vue/composition-api/dist/vue-composition-api.esm.js'
   )

(Update: PR nuxt-community/composition-api#517 and it's working for me)

from vue-demi.

ackushiw-flutterwave avatar ackushiw-flutterwave commented on May 25, 2024 2

Hi @danielroe I hadn't experienced this issue previously, but I just updated to the latest version and my netlify deploy now fails with:

Package subpath './dist/vue-composition-api.esm.js' is not defined by "exports" in /opt/build/repo/node_modules/@vue/composition-api/package.json

It generates fine locally, and reverting to the previous version works.

from vue-demi.

sibbng avatar sibbng commented on May 25, 2024 1

I guess that /dist/vue-composition-api.esm.js path have to be defined in @vue/composition-api's export map like how @nuxtjs/composition-api does.

from vue-demi.

TonyPythoneer avatar TonyPythoneer commented on May 25, 2024 1

I guess that /dist/vue-composition-api.esm.js path have to be defined in @vue/composition-api's export map like how @nuxtjs/composition-api does.

I try to find the source code from the @nuxtjs/composition-api
https://github.com/nuxt-community/composition-api/blob/1b07abeada072da79c1f0105d73389b799f4f8e1/src/module/index.ts#L29

I guess the reason from this.

from vue-demi.

antfu avatar antfu commented on May 25, 2024 1

Yeah the dilemma is that Vue CLI only happy with full js path, while Nuxt only happy with package name only, while Nuxt 3 want to have native esm support (also it's more future proof)

/cc @sodatea I think ideally we should have it work without fullpath, which I can't figure out why Vue CLI failed to resolve it, can you take a look a bit? (if you want we could have a pair-programming session)

from vue-demi.

danielroe avatar danielroe commented on May 25, 2024 1

@ackushiw-flutterwave would you raise a new issue with some more details and I'll look into this? 🙏 I take it you probably have not customised your Node version on Netlify?

from vue-demi.

Ricklin90085 avatar Ricklin90085 commented on May 25, 2024

@antfu thank you for reply !
I tried to upgrade the @vue/composition-api to verison 1.0.3
But it didn't work :(

Here is reproduction link: codesandbox
Are there any steps I missed or wrong?

from vue-demi.

TonyPythoneer avatar TonyPythoneer commented on May 25, 2024

I try to find the source code from the @nuxtjs/composition-api
nuxt-community/composition-api@1b07abe/src/module/index.ts#L29

@TonyPythoneer That's useful, thanks!

/cc @danielroe or do you think we could have one more alias like (I guess the alias is overkilled by replacing the submodules)

 nuxtOptions.alias['@vue/composition-api/dist/vue-composition-api.esm.js'] = 
   this.nuxt.resolver.resolveModule(
     '@vue/composition-api/dist/vue-composition-api.esm.js'
   )

(Update: PR nuxt-community/composition-api#517 and it's working for me)

Amazing! It's worked!
Thanks @antfu !

from vue-demi.

Ricklin90085 avatar Ricklin90085 commented on May 25, 2024

Hi @antfu @TonyPythoneer
I have tried both ways and both are worked!
Before the PR gets merged, I will use alias Property workaround to solve the problem.

Thanks a lot for your help. 👍👍
Can't wait to try @vueuse. :D

from vue-demi.

wheatjs avatar wheatjs commented on May 25, 2024

@ackushiw-flutterwave try clearing the netlify cache and redeploying

from vue-demi.

ackushiw-flutterwave avatar ackushiw-flutterwave commented on May 25, 2024

@wheatjs I tried that, but no luck, unfortunately. I've reverted for now.

from vue-demi.

Ricklin90085 avatar Ricklin90085 commented on May 25, 2024

Hi @danielroe
In my case, it fixed!
Thanks for your help :D

from vue-demi.

ackushiw-flutterwave avatar ackushiw-flutterwave commented on May 25, 2024

@danielroe That's correct, using Netlify's default setup node v12.18.0 (npm v6.14.4) and using yarn 1.22.10.

Should I create the new issue here?
https://github.com/nuxt-community/composition-api/issues

from vue-demi.

danielroe avatar danielroe commented on May 25, 2024

@ackushiw-flutterwave Yes, thank you 😊

from vue-demi.

ackushiw-flutterwave avatar ackushiw-flutterwave commented on May 25, 2024

@Kematia Thanks, that worked!

from vue-demi.

DavidVaness avatar DavidVaness commented on May 25, 2024

@Kematia thanks, that worked for me too

from vue-demi.

PeteJStewart avatar PeteJStewart commented on May 25, 2024

I also had this issue when running in CircleCI.
In my case I am also using the Cypress Orb, which uses node 12 by default.

I therefore needed to update the node version during the post-install command and also run the build process there, rather than via the cypress orb build command.

Ended up like so:

- cypress/install:
    post-install:
      - run:
          name: "Update node version & Build Nuxt"
          command: |
            wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
            export NVM_DIR="$HOME/.nvm"
            [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
            [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
            nvm install v16
            nvm alias default 16.14.2
            npm run build

from vue-demi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.