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

db:setup TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null #180

Closed
charlesdarkwind opened this issue Nov 19, 2020 · 4 comments

Comments

@charlesdarkwind
Copy link

I am doing the getting started, I have all the requirements, node installed, postgres running, I can login via pgadmin. I cloned the repo, yarn install,I entered the log in informations in the .envrc for DB_USER, DB_PASSWORD, etc. Everything above the "Database connection" section I did not change.

Then yarn db:setup gives this error:

λ yarn db:setup
yarn run v1.22.5
$ npm run db:create && npm run db:migrate
internal/crypto/keys.js:304
    throw new ERR_INVALID_ARG_TYPE(
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null
    at prepareSecretKey (internal/crypto/keys.js:304:11)
    at new Hmac (internal/crypto/hash.js:113:9)
    at Object.createHmac (crypto.js:143:10)
    at createHMAC (C:\Users\15148\Documents\conova\Pizzly\node_modules\pg\lib\sasl.js:133:17)
    at Hi (C:\Users\15148\Documents\conova\Pizzly\node_modules\pg\lib\sasl.js:137:13)
    at Object.continueSession (C:\Users\15148\Documents\conova\Pizzly\node_modules\pg\lib\sasl.js:32:24)
    at Connection.<anonymous> (C:\Users\15148\Documents\conova\Pizzly\node_modules\pg\lib\client.js:189:10)
    at Connection.emit (events.js:315:20)
    at C:\Users\15148\Documents\conova\Pizzly\node_modules\pg\lib\connection.js:109:10
    at Parser.parse (C:\Users\15148\Documents\conova\Pizzly\node_modules\pg-protocol\dist\parser.js:40:17) {
  code: 'ERR_INVALID_ARG_TYPE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@Frenchcooc
Copy link
Contributor

Frenchcooc commented Nov 23, 2020

Hi, here's the output that I have at the step yarn db:setup when following the Getting Started

➜  Pizzly git:(master) yarn db:setup
yarn run v1.22.4
$ npm run db:create && npm run db:migrate
npm WARN lifecycle The node binary used for scripts is /var/folders/s7/6n2pqdss23s5ls43x8wcct8h0000gn/T/yarn--1606125457164-0.7456167302932317/node but npm is using /Users/corentinbrossault/.fnm/node-versions/v10.16.3/installation/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> pizzly@0.2.0 db:create /Users/corentinbrossault/Bearer/tmp/Pizzly
> node dist/src/lib/database/config/create

npm WARN lifecycle The node binary used for scripts is /var/folders/s7/6n2pqdss23s5ls43x8wcct8h0000gn/T/yarn--1606125457164-0.7456167302932317/node but npm is using /Users/corentinbrossault/.fnm/node-versions/v10.16.3/installation/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> pizzly@0.2.0 db:migrate /Users/[filtered]/Pizzly
> knex --cwd dist/src/lib/database/config migrate:latest

Using environment: development
Already up to date
✨  Done in 1.78s.

Apart from the two warnings, it states that it successfully managed to initiate the database. So you have probably an issue with your local configuration. Can you share your .envrc (by filtering the credentials)?

@charlesdarkwind
Copy link
Author

Here is the content but I get the error no matter which env variables I fill or not.

###############################################################################
#
# Secure your instance
#
# 1. Secure access to the dashboard
#
export DASHBOARD_USERNAME=""
export DASHBOARD_PASSWORD=""
#
# 2. Secure requests to the API
#
export SECRET_KEY=""
export PUBLISHABLE_KEY=""
#
# 3. Allow or disable requests to the proxy service using a publishable key.
#    FALSE by default to allow request with a publishable key or a secret key.
#    Set to TRUE to only allow access having a valid secret key.
#
export PROXY_USES_SECRET_KEY_ONLY=FALSE
#
# 4. Replace the default cookie secret to an unguessable string
#    Learn more: https://github.com/expressjs/cookie-session
#
export COOKIE_SECRET="CHANGE_ME"
#
###############################################################################
#
# Database connection
#
# 1. Use a connection URI
#
# export DATABASE_URL=""
#
# 2. Provide specific database attributes
#
export DB_USER="postgres"
export DB_PASSWORD="my password"
export DB_HOST="the host"
export DB_PORT="5432"
export DB_DATABASE=""

@Frenchcooc
Copy link
Contributor

Got it. Sounds like an issue between your local configuration and the pg package. Have a look to this issue: brianc/node-postgres#2371 which looks very similar.

@charlesdarkwind
Copy link
Author

Thanks I think it works now after changing the conf file. I then had to set the env variables inside the windows variables manager because running the envrc did not appear to work.

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