Netlify dev Error

I want to use redirects in gatsby. I installed netlify-cli and added netlify.toml file in the root folder.

In netlify-toml file
[[redirects]]
from = “/search/*”
to = “/search”
status = 200

When I run netlify dev, I’ve got this following errors.
Warnings while parsing netlify.toml file:
TypeError: Cannot convert object to primitive value
at ~/npm-global/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:15:46
at Array.forEach ()
at parseFile (~/npm-global/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:14:19)
at async parseRules (~/npm-global/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:31:22)
at async createRewriter (~/npm-global/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:68:15)
at async startProxy (~/npm-global/lib/node_modules/netlify-cli/src/commands/dev/index.js:179:20)
at async DevCommand.run (~/npm-global/lib/node_modules/netlify-cli/src/commands/dev/index.js:449:19)
at async DevCommand._run (~/npm-global/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:42:20)
at async Config.runCommand (~/npm-global/lib/node_modules/netlify-cli/node_modules/@oclif/config/lib/config.js:172:9)
at async Main.run (~/npm-global/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/main.js:21:9)

1 Like

I removed [[redirects]] and it’s working.

hmm, that is a little frustrating.

I would suggest you take a look at the issues here: GitHub - netlify/cli: Netlify Command Line Interface

and see if there is anything that might already exist that documents this? If not, you could file an issue there so we can take a closer look.

Well that’s new. Which version of Netlify CLI are you running? And would you mind sharing the rest of your netlify.toml file if possible?


Jon

I removed [[redirects]] and it’s working. So I added [[redirects]] again to test it and it’s working. I am new to this. I am sorry I cannot provide any informative data. Thanks.

I can confirm this issue.
Now running: netlify-cli/2.48.0 darwin-x64 node-v13.11.0

By removing the redirects the issue is gone. With the previous netlify-cli version (sorry, I don’t know which version I was on) this wasn’t the case.

[build] 
  functions = "src/functions/"

[dev]
  command = "gatsby develop"
  port = 3000

[[redirects]]
  from = "/post"
  to = "/.netlify/functions/post"
  status = 200

[[redirects]]
  from = "/vuistje/*"
  to = "/show?id=:splat"
  status = 302
1 Like

I’m also facing the same issue and the same error as minheinkhant, I recently installed the netlify-cli (current tags 2.48.0) but the error still persist even i remove the [[redirects]] and added it back. Please consult. Thanks

1 Like

Getting this same issue. Removing the [[redirects]] seem to have solved it.

Env info:

$ netlify --version
netlify-cli/2.48.0 darwin-x64 node-v10.19.0

Error message:

...
Connected!
Waiting for localhost:34567.
Connected!
◈ Warnings while parsing netlify.toml file:
TypeError: Cannot convert object to primitive value
    at result.errors.forEach.err (~/.nvm/versions/node/v10.19.0/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:15:46)
    at Array.forEach (<anonymous>)
    at parseFile (~/.nvm/versions/node/v10.19.0/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:14:19)

netlify.toml file:

# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
  # Directory to change to before starting a build.
  # This is where we will look for package.json/.nvmrc/etc.
  # base = "project/"

  # Directory (relative to root of your repo) that contains the deploy-ready
  # HTML files and assets generated by the build. If a base directory has
  # been specified, include it in the publish directory path.
  publish = "public"

  # Directory with the serverless Lambda functions to deploy to AWS.
  functions = "public/lambda"

  # Default build command.
  command = "yarn build"

  # Directory with the serverless Lambda functions to deploy to AWS.
  # functions = "project/functions/"

# A redirect rule with all the supported properties
[[redirects]]
  from = "/index.html"
  to = "/"

[[redirects]]
  from = "/application.html"
  to = "/project/"

Any assistance appreciated!

@samajammin, @minheinkhant Thank you reporting this problem. We’ve just released a new version that contains a fix for this problem. Please upgrade to latest version npm i -g netlify-cli@latest and let us know if it is still an issue.

1 Like

@raeesbhatti just updated to netlify-cli/2.49.0 win32-x64 node-v10.16.3 and found that I am still getting a TypeError from rules-proxy.js when I include [[redirects]] in my netlify.toml file.

@Whatttooo is it possible for you to share your netlify.toml file. Please share the output of netlify version --verbose as well.

@raeesbhatti Netlify version info:

────────────────────┐
 Environment Info   │
────────────────────┘

  System:
    OS: Windows 10 10.0.18362
    CPU: (12) x64 AMD Ryzen 5 1600 Six-Core Processor
  Binaries:
    Node: 10.16.3 - C:\Program Files\nodejs\node.EXE
    npm: 6.11.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.18362.449.0

netlify-cli/2.49.0 win32-x64 node-v10.16.3

netlify.toml:

[build]
  functions = 'functions'
  publish = 'public'

[[redirects]]
  from = '/api/*'
  to = '/.netlify/functions/:splat'
  status = 200

Same here — still getting the error.

────────────────────┐
 Environment Info   │
────────────────────┘

  System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.0.0 - /usr/local/bin/node
    npm: 6.14.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 81.0.4044.129
    Firefox: 68.0.1
    Safari: 13.0.5
  npmGlobalPackages:
    netlify-cli: 2.49.0

netlify-cli/2.49.0 darwin-x64 node-v14.0.0

This was hard to reproduce but I was able to track it down. The error is coming from a dependency which has been patched. There’s a PR to upgrade the dependencies in netlify-cli.

It might be worth trying to install netlify-cli globally again using npm i -g netlify-cli@latest, since we’re using ^ dependencies, npm should pick up the new versions. If it doesn’t work, please hold on until we release a new version. I’ll upgrade this thread when we do.

1 Like

I’m confirming that after installing netlify-cli@2.49.0, the issue is resolved for me. I’m able to start my project with netlify dev with:

[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/:splat"
  status = 200

in netlify.toml, without the TypeError: Cannot convert object to primitive value error that was reported earlier. Thanks for taking quick action on this!

1 Like

thanks for letting us know!

1 Like

netlify-cli@2.50 has just been released which contains fix for this issue. Thank you all for your patience!

1 Like

Thanks a lot! Already installed and tested it, issue solved :smile:

Installed and tested too! Thank you @raeesbhatti :smiley:

1 Like

Thanks @raeesbhatti - I installed netlify-cli@2.50 & running netlify dev now works with no errors, but my redirects no longer appear to be working:

You can see my full netlify.toml file posted above - hitting /application.html should redirect to /project/ :

[[redirects]]
  from = "/application.html"
  to = "/project/"

Here’s my env:

$ netlify version --verbose
────────────────────┐
 Environment Info   │
────────────────────┘

  System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.19.0 - ~/.nvm/versions/node/v10.19.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v10.19.0/bin/npm
  Browsers:
    Chrome: 81.0.4044.138
    Firefox: 74.0
    Safari: 13.1
  npmGlobalPackages:
    netlify-cli: 2.50.0

netlify-cli/2.50.0 darwin-x64 node-v10.19.0

Thanks in advance for your help!