In a food processor, combine the pine nuts, lemon juice (if using), garlic, salt, black pepper, and red pepper flakes. Pulse until the pine nuts are finely chopped and the ingredients are well combined, scraping the sides of the processor bowl with a rubber spatula.
Add the basil and pulse to combine. With the food processor running, slowly stream in the oil until well combined. Add the parmesan cheese and pulse to combine.
Store the pesto in an airtight container for up to one week.
