0

So basically, on the get-go when I try to run my project under Visual Studio using full stack React and ASP.NET Core, I get this error

"C:\Program Files\nodejs\node.exe" --import file:/C:/Program%20Files/JetBrains/WebStorm%202024.2.4/plugins/nodeJS/js/ts-file-loader/node_modules/tsx/dist/loader.cjs "C:\Users\main\Documents\Programming\Project and Freelance\projects\VehicleRentalProject\vehiclerentalproject.client\vite.config.ts"

There was an error exporting the HTTPS developer certificate to a file.
file:///C:/Users/main/Documents/Programming/Project%20and%20Freelance/projects/VehicleRentalProject/vehiclerentalproject.client/vite.config.ts:1
import{fileURLToPath,URL}from"node:url";import{defineConfig}
from"vite";import plugin from"@vitejs/plugin-react";import fs from"fs";import path from"path";import child_process from"child_process";import{env}from"process";const baseFolder=env.APPDATA!==void 0&&env.APPDATA!==""?${env.APPDATA}/ASP.NET/https:${env.HOME}/.aspnet/https;const certificateName="vehiclerentalproject.client";const certFilePath=path.join(baseFolder,${certificateName}.pem);const keyFilePath=path.join(baseFolder,${certificateName}.key);if(!fs.existsSync(certFilePath)||!fs.existsSync(keyFilePath)){if(0!==child_process.spawnSync("dotnet",["dev-certs","https","--export-path",certFilePath,"--format","Pem","--no-password"],{stdio:"inherit"}).status){throw new Error("Could not create certificate.")}}const target=env.AS PNETCORE_HTTPS_PORT?https://localhost:${env.ASPNETCORE_HTTPS_PORT}:env.ASPNETCORE_URLS?env.ASPNETCORE_URLS.split(";")[0]:"https://localhost:7017";var vite_con fig_default=defineConfig({plugins:[plugin()],resolve:{alias:{"@":fileURLToPath(new URL("./src",import.meta.url))}},server:{proxy:{"^/weatherforecast":{target,secure:false}},port:5173,https:{key:fs.readFileSync(keyFilePath),cert:fs.readFileSync(certFilePath)}}});export{vite_config_default as default}; > Error: Could not create certificate.

I checked the path, and the certificate already exists. Also, it seems as though there is also a similar bug like this on the Angular ASP.NET Core side, and solves it by modifying the aspnetcore-https.js file

const baseFolder = //etc...

fs.mkdirSync(baseFolder, { recursive: true });

But I can't find the aspnetcore-https.js file or even its equivalent.

1 Answer 1

0

The issue has been discussed here.It' a .Net 8 build bug and Version >= 8.0.403 are affected ,you could try to install a former version and switch the dotnet sdk version when you debug

For example,via gobal.json

dotnet new globaljson --sdk-version 8.0.402
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.