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

Weird error if no name field in package.json #335

Closed
lcswillems opened this issue Feb 18, 2021 · 4 comments · Fixed by blitz-js/blitz#1963
Closed

Weird error if no name field in package.json #335

lcswillems opened this issue Feb 18, 2021 · 4 comments · Fixed by blitz-js/blitz#1963

Comments

@lcswillems
Copy link
Contributor

Steps to Reproduce

Create a new Blitzjs app: npx blitz new blitz-app

Remove the name field from the package.json file.

Run yarn build.

This gives this error:

TypeError: Cannot read property 'replace' of undefined
    at ee (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/@blitzjs/core/dist/core.cjs.production.min.js:1:5987)
    at re (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/@blitzjs/core/dist/core.cjs.production.min.js:1:6380)
    at d (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:34:498)
    at bb (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:37:16)
    at a.b.render (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:43:48)
    at a.b.read (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:83)
    at exports.renderToStaticMarkup (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:446)
    at renderDocument (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/next/dist/next-server/server/render.js:3:715)
    at renderToHTML (/mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/next/dist/next-server/server/render.js:56:103)
    at async /mnt/Data/Documents/Travail/Personnel/Projets/Ouverts/Miple/Code/lab/blitz-app/node_modules/next/dist/export/worker.js:26:6
@lcswillems lcswillems changed the title Wierd error if no name field in package.json Weird error if no name field in package.json Feb 18, 2021
@flybayer
Copy link
Member

Hey thanks!

Here's the line that needs fixed: https://github.com/blitz-js/blitz/blob/canary/packages/core/src/blitz-data.tsx#L14

If package.json name isn't available, we should default to "blitz" as the name

@lcswillems
Copy link
Contributor Author

Thank you for the fix!

@lcswillems
Copy link
Contributor Author

I don't know if it is a good idea to base the name of the cookies on the name of the project. It is an unexpected behavior from my side. I would have never expected that changing the name of the project would log out all my users...

@flybayer
Copy link
Member

@lcswillems excellent point. I opened an issue for that: https://github.com/blitz-js/blitz/issues/1972

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.

2 participants