error with npm run build
Kernix13 opened this issue · comments
I added the site property and added the function call to integrations but I got the following error:
robotsTxt is not defined
ReferenceError: robotsTxt is not defined
Here is my config file:
import { defineConfig } from 'astro/config';
// https://astro.build/config
import sitemap from "@astrojs/sitemap";
// https://astro.build/config
export default defineConfig({
vite: {
ssr: {
external: ['svgo']
}
},
site: 'https://kernixwebdesign.com',
integrations: [sitemap(), robotsTxt()]
});
Any idea what the issue is?
Also, if I can't get it working, do I have to uninstall it? And if so, how do I do that?
Hello!
Judging by your code, you simply forgot to import the astro-robots-txt integration.
Just add the following line to the beginning: import robotsTxt from 'astro-robots-txt';
Missed that. I just added it and now the error is:
Cannot find package 'astro-robots-txt' imported from C:\Users\pc\Documents\WebDev\astro\astro-figma-project\astro.config.mjs
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'astro-robots-txt' imported from C:\Users\pc\Documents\WebDev\astro\astro-figma-project\astro.config.mjs
I missed this:
✖ astro-robots-txt doesn't appear to be an integration or an adapter. Find our official integrations at https://astro.build/integrations
Could you provide more details about your project: package.json
etc?
Have you installed the astro-robots-txt
?
I ran npx astro add astro-robots-txt
and entered y
when prompted. Here is my package.json file:
{
"name": "@example/minimal",
"type": "module",
"version": "0.0.1",
"private": true,
"browserslist": [
"defaults"
],
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/sitemap": "^1.0.0",
"astro": "^1.9.0",
"astro-icon": "^0.8.0"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
"open-props": "^1.5.3",
"postcss": "^8.4.20",
"postcss-jit-props": "^1.0.9"
}
}
Thanks. I will check npx
command a bit later.
For now pls run:
npm i -D astro-robots-txt
It will install the integration.
Thanks for issue.
The npx astro add astro-robots-txt
command hasn't worked properly with this integration after some astro minor updates.
It's just fixed in v0.3.11 of astro-robots-txt.
So use the npx
command or the npm
command you listed above?
The npx
command worked - thanks! Closes #42.