const fs = require('fs'); const path = 'd:/front-end/hdApp/src/admin/home/workbench.vue'; let content = fs.readFileSync(path, 'utf8'); // Remove duplicate template junk between first and `; const stylePart = content.slice(styleStart); content = content.slice(0, scriptStart) + newScript + stylePart; fs.writeFileSync(path, content); console.log('trimmed workbench');