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

Cannot read properties of undefined (reading 'info') #220

Closed
antinmaze opened this issue Apr 25, 2024 · 3 comments
Closed

Cannot read properties of undefined (reading 'info') #220

antinmaze opened this issue Apr 25, 2024 · 3 comments

Comments

@antinmaze
Copy link

antinmaze commented Apr 25, 2024

What version of astro-icon are you using?

v1.9.2

Astro Info

with the v1.9.2 version, the info command does not exist:
 % npx astro help

   astro  v1.9.2 Build faster websites.

  astro [command] [...flags]

   Commands 
                add  Add an integration.
              build  Build your project and write it to disk.
              check  Check your project for errors.
                dev  Start the development server.
               docs  Open documentation in your web browser.
            preview  Preview your build locally.
               sync  Generate content collection types.
          telemetry  Configure telemetry settings.

   Global Flags 
    --config <path>  Specify your config file.
      --root <path>  Specify your project root folder.
       --site <url>  Specify your project site.
  --base <pathname>  Specify your project base.
          --verbose  Enable verbose logging.
           --silent  Disable all logging.
          --version  Show the version number and exit.
             --help  Show this help message.

If this issue only occurs in one browser, which browser is a problem?

chrome, Firefox

Describe the Bug

After installing astro-icon and creating a /src/icons/plus-circle.svg file
I have the following code:
`---
const { sectionName, sectionUrl, sectionItems } = Astro.props;
import { Icon } from 'astro-icon/components'

<div class="pb-3">
  <h1 class="flex pb-3 text-3xl">{sectionName}
    <a class="add-item  text-gray-700 dark:text-white" href={sectionUrl}>
      <Icon name="plus-circle" />
    </a>
  </h1>
  </div>

I have the follkowing issue executing 'npm run dev';

11:55:10 [build] output target: static
11:55:10 [build] Collecting build info...
11:55:10 [build] Completed in 10ms.
11:55:10 [build] Building static entrypoints...
[astro-icon] Could not load virtual:astro-icon (imported by node_modules/astro-icon/components/Icon.astro): Cannot read properties of undefined (reading 'info')
 error   Could not load virtual:astro-icon (imported by node_modules/astro-icon/components/Icon.astro): Cannot read properties of undefined (reading 'info')
TypeError: Could not load virtual:astro-icon (imported by node_modules/astro-icon/components/Icon.astro): Cannot read properties of undefined (reading 'info')
    at logCollections (file:///Users/toto/Workspace/toto-astro/node_modules/astro-icon/dist/vite-plugin-astro-icon.js:46:12)
    at Object.load (file:///Users/toto/Workspace/toto-astro/node_modules/astro-icon/dist/vite-plugin-astro-icon.js:30:17)
    at async file:///Users/toto/Workspace/toto-astro/node_modules/rollup/dist/es/shared/rollup.js:21919:98
    at async Queue.work (file:///Users/toto/Workspace/toto-astro/node_modules/rollup/dist/es/shared/rollup.js:22858:32)
> [email protected] dev

What's the expected result?

Not having this message "Cannot read properties of undefined (reading 'info')" which is displayed in the browser

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-f8ywpn?file=src%2Fpages%2Findex.astro

@antinmaze
Copy link
Author

upgrading astro to astro v4.7.0 solved this issue using
npx @astrojs/upgrade

@nemanjam
Copy link

nemanjam commented Apr 28, 2024

I still get this:

Warning: ReactDOMServer.renderToStaticNodeStream() is deprecated. Use ReactDOMServer.renderToPipeableStream() and wait to `pipe` until the `onAllReady` callback has been called instead.
11:02:34 [ERROR] Cannot find module 'virtual:astro-icon' imported from '/home/username/Desktop/....github.io/node_modules/astro-icon/components/Icon.astro'
  Stack trace:
     at nodeImport (file:///home/username/Desktop/....github.io/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:55067:25)
     at eval (/home/username/Desktop/....github.io/node_modules/astro-icon/components/Icon.astro:4:37)

Adding it to integrations solved it.

import icon from "astro-icon";

export default defineConfig({
  integrations: [icon()],
});

But this remains:

Warning: ReactDOMServer.renderToStaticNodeStream() is deprecated. Use ReactDOMServer.renderToPipeableStream() and wait to `pipe` until the `onAllReady` callback has been called instead.

@antinmaze antinmaze reopened this May 1, 2024
@antinmaze
Copy link
Author

@nemanjam using manual installation. can lead to misconfiguration.
The quick installation command works managing all the configurations.
Do not have an issue with the last version
"astro": "^4.7.0",
"astro-icon": "^1.1.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants