Blitz: [Linux] getting "Object.fromEntries is not a function" when retrieving dependencies

Created on 1 May 2020  ·  8Comments  ·  Source: blitz-js/blitz

What is the problem?

I can't create a new project because the blitz cli can't retrieve the dependencies

Steps to Reproduce:

  1. Clear npm module cache (if it exists and blitz's project dependencies are in there)
  2. Create a new project using
    blitz new myapp

Versions:

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

Linux 4.19 | linux-x64 | Node: v10.20.1

blitz: 0.8.0 (global)

Supporting Documentation

Here is the exact error i'm getting

◤ Retrieving the freshest of dependenciesTypeError: Object.fromEntries is not a function
    at /usr/local/lib/node_modules/blitz/node_modules/@blitzjs/cli/lib/src/utils/fetch-latest-version-for.js:22:23
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/blitz/node_modules/tslib/tslib.js:110:62)

(this is after the project's file structure is created)

good first issue kinbug scopcli statudone

All 8 comments

Thanks for reporting this issue @pcrunn 👍 we will look into this asap.

Btw, I just checked this out and I'm also have a problem with generating.

Linux 4.19 | linux-x64 | Node: v13.13.0

blitz: 0.8.0 (global)

Couldn't find any versions for "eslint-plugin-react-hooks" that matches "39"
Error: Failed running prettier
    at AppGenerator.<anonymous> (~/.npm-global/lib/node_modules/blitz/node_modules/@blitzjs/cli/lib/src/generators/app.js:127:27)
    at Generator.next (<anonymous>)
    at fulfilled (~/.npm-global/lib/node_modules/blitz/node_modules/tslib/tslib.js:110:62)

@pcrunn this should be fixed in 0.8.1 — can you test and verify?

@pcrunn this should be fixed in 0.8.1 — can you test and verify?

hmmm, not sure about that. i'm still getting the same error

It seems the error occurs here:
https://github.com/blitz-js/blitz/blob/canary/packages/generator/src/utils/fetch-latest-version-for.ts#L29

Object.fromEntries() is supported from Node.js ver. 12.x .
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries

// test.js
const entries = new Map([
  ['foo', 'bar'],
  ['baz', 42]
]);

const obj = Object.fromEntries(entries);

console.log(obj);
// expected output: Object { foo: "bar", baz: 42 }
$ node --version
v10.20.1
$ node test.js
/Users/horie/work/BugInvestigation/github.com/blitz-js/blitz/425/test.js:6
const obj = Object.fromEntries(entries);
                   ^

TypeError: Object.fromEntries is not a function
    at Object.<anonymous> (/Users/horie/work/BugInvestigation/github.com/blitz-js/blitz/425/test.js:6:20)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
$ node --version
v12.0.0
$ node test.js
{ foo: 'bar', baz: 42 }

@is2ei that's what I thought, but the @pcrunn said he has Node: v10.20.1, which doesn't make sense. 🤔

We can either refactor this or add a polyfill or something

@flybayer

he has Node: v10.20.1

That is why he found the error. If he uses 12.x , he won't get the error.

We can either refactor this or add a polyfill or something

I agree with you.

Was this page helpful?
0 / 5 - 0 ratings