Blitz: [MacOS] Module Import error on Scaffold Code

Created on 4 May 2020  路  12Comments  路  Source: blitz-js/blitz

What is the problem?

I have created a scaffold with command blitz generate recipe. generated code has module import error for queries and mutation.

Screenshot 2020-05-04 at 12 45 28 PM

Versions:

checklist-app $ blitz --version --verbose
You are using alpha software - if you have any problems, please open an issue here:
  https://github.com/blitz-js/blitz/issues/new/choose

debug: global
debug: pkgPath: /usr/local/lib/node_modules/blitz/node_modules/@blitzjs/cli/lib/src/index.js 

macOS Catalina | darwin-x64 | Node: v12.16.2

blitz: 0.8.1 (global)

Result

Screenshot 2020-05-04 at 12 52 54 PM

Screenshot 2020-05-04 at 12 49 03 PM

kinbug kinduplicate scopcli scopserver

Most helpful comment

@gielcobben Got it. i think the scaffold missed the folder structure on import. when i change it, the error is gone.

CREATE    app/recipes/pages/recipes/[id]/edit.tsx
CREATE    app/recipes/pages/recipes/[id].tsx
CREATE    app/recipes/pages/recipes/index.tsx
CREATE    app/recipes/pages/recipes/new.tsx
CREATE    app/recipes/queries/recipes/getRecipe.ts
CREATE    app/recipes/queries/recipes/getRecipes.ts
CREATE    app/recipes/mutations/recipes/createRecipe.ts
CREATE    app/recipes/mutations/recipes/deleteRecipe.ts
CREATE    app/recipes/mutations/recipes/updateRecipe.ts

All 12 comments

Thanks for the issue! Could you try:

  1. rm -rf .blitz

  2. blitz start again

And see if that makes any difference?

you mean blitz start. i tried it and it outputs like.

Screenshot 2020-05-04 at 1 03 39 PM

i could solve this issue by importing it like

Screenshot 2020-05-04 at 1 04 46 PM

Hi @ganeshmani, thank you for submitting an issue.

@merelinguist Is this similar to https://github.com/blitz-js/blitz/issues/193? My comment in the aforementioned issue https://github.com/blitz-js/blitz/issues/193#issuecomment-623038968 seems similar, don't it? This might be a duplicate issue.

@simonpeterdebbarma Not sure about that, since @ganeshmani is using macOS.

@merelinguist Are the packages different for Mac and Windows?

Yes. From the looks of it, #193 is related to specific problems related to running child_process on Windows. This error looks more like a cross-platform issue.

When I use blitz generate all recipe it created these files:

CREATE    app/recipes/pages/recipes/[id]/edit.tsx
CREATE    app/recipes/pages/recipes/[id].tsx
CREATE    app/recipes/pages/recipes/index.tsx
CREATE    app/recipes/pages/recipes/new.tsx
CREATE    app/recipes/queries/recipes/getRecipe.ts
CREATE    app/recipes/queries/recipes/getRecipes.ts
CREATE    app/recipes/mutations/recipes/createRecipe.ts
CREATE    app/recipes/mutations/recipes/deleteRecipe.ts
CREATE    app/recipes/mutations/recipes/updateRecipe.ts

that means that the import in your code is wrong. It should be:

import getRecipes from app/recipes/queries/recipes/getRecipes.ts

@gielcobben Got it. i think the scaffold missed the folder structure on import. when i change it, the error is gone.

CREATE    app/recipes/pages/recipes/[id]/edit.tsx
CREATE    app/recipes/pages/recipes/[id].tsx
CREATE    app/recipes/pages/recipes/index.tsx
CREATE    app/recipes/pages/recipes/new.tsx
CREATE    app/recipes/queries/recipes/getRecipe.ts
CREATE    app/recipes/queries/recipes/getRecipes.ts
CREATE    app/recipes/mutations/recipes/createRecipe.ts
CREATE    app/recipes/mutations/recipes/deleteRecipe.ts
CREATE    app/recipes/mutations/recipes/updateRecipe.ts

@simonpeterdebbarma i would like to take up this issue if anybody is not working on it.

Sure, go ahead. Thank you very much!

Hey y'all! We are tracking this issue here: https://github.com/blitz-js/blitz/issues/402

Should have a hot fix soon.

This is fixed in blitz 0.8.2!

Was this page helpful?
0 / 5 - 0 ratings