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

Relative asset plugin broken #13439

Closed
liaoyu1992 opened this issue Mar 2, 2022 · 18 comments · Fixed by nuxt/framework#3499
Closed

Relative asset plugin broken #13439

liaoyu1992 opened this issue Mar 2, 2022 · 18 comments · Fixed by nuxt/framework#3499

Comments

@liaoyu1992
Copy link

Environment

window10
nodejs: v16.14.0

Reproduction

GET http://localhost:3000/main-62bdb63b.mjs net::ERR_ABORTED 404 (Page not found: /main-62bdb63b.mjs)
GET http://localhost:3000/main.4f570753.css net::ERR_ABORTED 404 (Page not found: /main.4f570753.css)
entry-dfffb6f1.mjs:8 Event {isTrusted: true, type: 'error', target: link, currentTarget: link, eventPhase: 2, …}
Uncaught (in promise) Event {isTrusted: true, type: 'error', target: link, currentTarget: null, eventPhase: 0, …}

Describe the bug

When I'm routing to a certain page,for example:
router.push({ name: 'main'}),
then report the above error

Additional context

No response

Logs

No response

@phanmn
Copy link

phanmn commented Mar 2, 2022

Seeing this issue also

@phanmn
Copy link

phanmn commented Mar 2, 2022

  • In normal entry file (entry-xxxxxx.mjs)

Screen Shot 2022-03-02 at 15 51 56

  • In bug entry file ((entry-xxxxxx.mjs)

Screen Shot 2022-03-02 at 15 52 27

@danielroe danielroe added vite and removed nuxt3 labels Mar 2, 2022
@danielroe
Copy link
Member

Would you provide a reproduction? 🙏

@oritwoen
Copy link
Contributor

oritwoen commented Mar 2, 2022

@danielroe please check also unocss/unocss#676 the error looks similar

@dualmacops
Copy link

I have the same problem, but it looks like it only happens on the / route, not in the others

@Denoder
Copy link

Denoder commented Mar 3, 2022

seems to happen on this commit precisely: nuxt/framework@a0f8a44

@hi-reeve
Copy link

hi-reeve commented Mar 3, 2022

got the same issues in preview mode but not with the route but with the component

@danielroe danielroe changed the title net::ERR_ABORTED 404 (Page not found: /main-62bdb63b.mjs) Missing resources (hashes don't match) when app is built Mar 3, 2022
@xiao-e-yun
Copy link

hashes match is true
but miss buildAssetsDir or _nuxt/ ( cdnURL work

@peteromano
Copy link

peteromano commented Mar 3, 2022

Same.

Doesn't look like hashes in my case; column (a layout), is loaded correctly initially then attempted to load again under the root (not _nuxt).. Also, not sure why the entire app is completely broken from this.

image

@peteromano
Copy link

is there a workaround for now or proposed fix to wait on?

@Denoder
Copy link

Denoder commented Mar 3, 2022

@peteromano for now you can use 3.0.0-27434608.0c99002 as the nuxt3 version until it's fixed

@xiao-e-yun
Copy link

xiao-e-yun commented Mar 4, 2022

This is my temporary solution
it may not be the best but it works

node ./deploy.mjs

~/deploy.mjs

import fs from 'node:fs/promises';
import path from 'node:path';

const p = "/_nuxt/"

const __dirname = new URL(".",import.meta.url).pathname
const from = path.resolve(__dirname,".output/public"+p)

try {
  let files = await fs.readdir(from)
  files = files.filter(v=>v.startsWith("entry-") && v.endsWith(".mjs"))

  if (files.length) {
    const file = path.resolve(from,files[0])
    let data = await fs.readFile(file,{encoding:"utf-8"})

    const replace = []
    const regex = /import\("(.*?)\.mjs"\)/gm
    let match = undefined

    data = data.replaceAll("./","")

    for (;;) {
      match = regex.exec(data)
      if(match===null) break
      replace.push(match[1])
    }

    replace.forEach(v=>{
      const css = new RegExp(v.slice(0,v.indexOf("-"))+"\.(.{8})\.css")
      data = data.replaceAll(v+".mjs",path.resolve(p,v+".mjs"))
      data = data.replace(css,p+"$&")
    })
    await fs.writeFile(file,data)
  }
} catch(e) {
  console.error(e)
}

@danielroe danielroe changed the title Missing resources (hashes don't match) when app is built Relative asset plugin broken on vite Mar 4, 2022
@danielroe danielroe changed the title Relative asset plugin broken on vite Relative asset plugin broken Mar 4, 2022
@danielroe danielroe self-assigned this Mar 4, 2022
@lukeocodes
Copy link

lukeocodes commented Mar 4, 2022

@peteromano for now you can use 3.0.0-27434608.0c99002 as the nuxt3 version until it's fixed

This release did resolve it for me for now.

  "devDependencies": {
    "nuxt3": "3.0.0-27434608.0c99002",
  }

@bmhtech07
Copy link

bmhtech07 commented Mar 6, 2022

@peteromano for now you can use 3.0.0-27434608.0c99002 as the nuxt3 version until it's fixed

This worked for me. Thanks!

@danielroe
Copy link
Member

@bmhtech07 This bug should not be present in the current version of Nuxt. If it is, would you open a new issue with a reproduction?

@bmhtech07
Copy link

False alarm. Staging branch hadn't been updated! Now fine!

@ennioVisco
Copy link
Contributor

ennioVisco commented Apr 2, 2022

@bmhtech07 This bug should not be present in the current version of Nuxt. If it is, would you open a new issue with a reproduction?

@danielroe it seems to be present again in 3.0.0-27480376.fdd38f9. Rolling back to that commit solves it

@danielroe
Copy link
Member

@ennioVisco Would you open a new issue with a reproduction?

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.