question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`fastify start` command is throwing `missing file parameter` error on Windows

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure it has not already been reported

Fastify version

^3.15.1

Node.js version

15.14.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

2004

Description

I just joined a project that uses fastify as their backend framework of choice and we have the following npm script to launch the server during development:

fastify start -w server/fastify.js --options --ignore-watch='out.csv node_modules ui .nyc_output' | pino-pretty

I managed to run this on Windows Sub-system for Linux (WSL), but not on the native powershell. Whenever I try to run this on powershell I get the following error:

Missing the required file parameter

Usage: fastify start [opts] <file> [--] [<plugin-options>]

But from what I can tell, we are specifying the file parameter as server/fastify.js in the script.

Any idea why this fails on Windows, but works fine on WSL? Both my Windows and WSL have the same versions of Node and npm and are running on the same laptop.

It also works fine on my colleagues Macs as well, in case that helps diagnose this.

This is my first fastify project, so I’m not entirely sure what to be looking for to self-diagnose. I’d be happy to provide any further details if needed.

Steps to Reproduce

I think it should be easy enough to reproduce with any simple fastify project, with the file to launch the server in a server/ folder, rather than the root.

Expected Behavior

I generally expect it work on Windows as well, when it works on Linux and Mac.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
simonebcommented, May 13, 2021

@UmarGhouse replace single quotes with double quotes. If an npm script, escape them with backslashes, e.g.

"start": "fastify start -w server/fastify.js --options --ignore-watch=\"out.csv node_modules ui .nyc_output\" | pino-pretty"
0reactions
UmarGhousecommented, May 13, 2021

Thanks @simoneb ! It works when I use double quotes instead of single ones (escaped with backslashes as shown). Tested the same on WSL and it works there as well! Just the bcrypt error left, but I think I can solve that by re-installing my packages.

So, I think we can close this issue 🙂. Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: plugin must be a function · Issue #262 - GitHub
This is a bug on fastify-cli , it really needs to print a better error message. Specifically, the function must supply three parameters....
Read more >
Errors - Fastify
In Node.js, uncaught errors are likely to cause memory leaks, file ... or the received error parameter re-thrown) - will call the parent...
Read more >
Server - Fastify
serverFactory is a function that takes a handler parameter, which takes the request and response objects as parameters, and an options object, which...
Read more >
Ecosystem - Fastify
An error handling plugin for Fastify that uses enhanced HTTP errors. Redirect HTTP requests to HTTPS, both using the same port number, or...
Read more >
Getting-Started - Fastify
This document aims to be a gentle introduction to the framework and its features. ... catch (err) { fastify.log.error(err) process.exit(1) } } start()....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found