diff --git a/packages/create-app/index.js b/packages/create-app/index.js index 489c7f02ace65b..0cc1af168e6bfd 100755 --- a/packages/create-app/index.js +++ b/packages/create-app/index.js @@ -118,7 +118,15 @@ async function init() { } const pkg = require(path.join(templateDir, `package.json`)) - pkg.name = path.basename(root) + + pkg.name = path + .basename(root) + // #2360 ensure packgae.json name is valid + .trim() + .replace(/\s+/g, '-') + .replace(/^[._]/, '') + .replace(/[~)('!*]+/g, '-') + write('package.json', JSON.stringify(pkg, null, 2)) const pkgManager = /yarn/.test(process.env.npm_execpath) ? 'yarn' : 'npm'