nuxt-modules / robots

Tame the robots crawling and indexing your Nuxt site.
https://nuxtseo.com/robots
MIT License
424 stars 34 forks source link

Doesn't work with windows and Nuxt3 #86

Closed alexiokay closed 4 months ago

alexiokay commented 1 year ago

https://github.com/nuxt-community/robots-module/issues/64

ERROR [worker reload] [worker init] Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' at new NodeError (node:internal/errors:371:5) at defaultResolve (node:internal/modules/esm/resolve:1016:11) at ESMLoader.resolve (node:internal/modules/esm/loader:422:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40) at link (node:internal/modules/esm/module_job:75:36)

seangwright commented 1 year ago

Same, here's my error:

 ERROR  (node:23052) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

√ Nitro built in 492 ms                                                                   nitro 15:17:22
i Vite client warmed up in 3593ms                                                               15:17:22

 ERROR  [worker reload] [worker init] Only URLs with a scheme in: file, data are supported by the default 
ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'

  at new NodeError (node:internal/errors:393:5)
  at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1026:11)
  at defaultResolve (node:internal/modules/esm/resolve:1106:3)
  at nextResolve (node:internal/modules/esm/loader:163:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)                        15:17:16  
  at link (node:internal/modules/esm/module_job:75:36)

ENV

Windows 10

> node -v
v18.12.1

package.json

  "dependencies": {
    "highlight.js": "11.7.0",
    "vue-gtag-next": "1.14.0"
  },
  "devDependencies": {
    "autoprefixer": "10.4.13",
    "nuxt": "3.0.0",
    "postcss": "8.4.19",
    "prettier": "2.8.0",
    "tailwindcss": "3.2.4",
    "typescript": "4.9.3",
    "vue-tsc": "1.0.11"
  },
  "engines": {
    "node": ">= 18.12.1"
  }
MuhammadM1998 commented 1 year ago

Same error on nuxt dev. nuxt generate works

 ERROR  [worker reload] [worker init] Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'e:'

  at new NodeError (node:internal/errors:393:5)  at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:986:11)
  at defaultResolve (node:internal/modules/esm/resolve:1066:3)
  at nextResolve (node:internal/modules/esm/loader:161:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:831:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:413:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
  at link (node:internal/modules/esm/module_job:76:36)
MuhammadM1998 commented 1 year ago

Anyone got this to work?

Slowhalfframe commented 1 year ago

Same error on nuxt dev. nuxt generate works

 ERROR  [worker reload] [worker init] Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'e:'

  at new NodeError (node:internal/errors:393:5)  at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:986:11)
  at defaultResolve (node:internal/modules/esm/resolve:1066:3)
  at nextResolve (node:internal/modules/esm/loader:161:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:831:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:413:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
  at link (node:internal/modules/esm/module_job:76:36)

Same mistake.

Gumbraise commented 1 year ago

Hey guys, I maybe solved the issue. Create a file named robots.config.ts on your Nuxt root. And add this is it:

export default [
    { UserAgent: '*' },
    { Disallow: '/' },
    { BlankLine: true },
    { Comment: 'Comment here' },

    { Sitemap: (req) => `https://${req.headers.host}/sitemap.xml` }
]

This solved the issue for me

MuhammadM1998 commented 1 year ago

@Gumbraise What you done is a workaround. The issue is not in the robots module itself

Createitv commented 1 year ago

Hey guys, I maybe solved the issue. Create a file named robots.config.ts on your Nuxt root. And add this is it:

export default [
    { UserAgent: '*' },
    { Disallow: '/' },
    { BlankLine: true },
    { Comment: 'Comment here' },

    { Sitemap: (req) => `https://${req.headers.host}/sitemap.xml` }
]

This solved the issue for me

Thanks! This also work for me

Hossara commented 1 year ago

Hey guys, I maybe solved the issue. Create a file named robots.config.ts on your Nuxt root. And add this is it:

export default [
    { UserAgent: '*' },
    { Disallow: '/' },
    { BlankLine: true },
    { Comment: 'Comment here' },

    { Sitemap: (req) => `https://${req.headers.host}/sitemap.xml` }
]

This solved the issue for me

This also work for me. Thanksssssss a lot.

kordoulakis commented 1 year ago

Workaround worked for me in Nuxt 3 as well.

Hey guys, I maybe solved the issue. Create a file named robots.config.ts on your Nuxt root. And add this is it:

export default [
    { UserAgent: '*' },
    { Disallow: '/' },
    { BlankLine: true },
    { Comment: 'Comment here' },

    { Sitemap: (req) => `https://${req.headers.host}/sitemap.xml` }
]

This solved the issue for me

Xyrai commented 1 year ago

Since this seems to be the current fix, make sure that the set values align with your robots.txt requirements before copy pasting the content.

Hey guys, I maybe solved the issue. Create a file named robots.config.ts on your Nuxt root. And add this is it:

export default [
    { UserAgent: '*' },
    { Disallow: '/' },
    { BlankLine: true },
    { Comment: 'Comment here' },

    { Sitemap: (req) => `https://${req.headers.host}/sitemap.xml` }
]

This solved the issue for me