0

When I run npm run build I get this error:

> plugin-test@0.1.0 build-esm
> BABEL_OUTPUT=esm babel src --extensions ".ts,.tsx,.js,.jsx" --copy-files --out-dir esm

"BABEL_OUTPUT" не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.
(translated from Russian: "BABEL_OUTPUT" is not a recognised internal or external command)

I've installed babel-core, babel-cli and babel-node and still get this error. I see the command that gets executed in my package.json:

"build-esm": "BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir esm",

Any Ideas how to solve this?

  • 1
    That's not how you set environment variables in Windows. Evidently your package is set up for *nix development. Related: https://stackoverflow.com/q/52902986/3001761, https://stackoverflow.com/q/26262196/3001761, ... – jonrsharpe Aug 01 '22 at 15:12
  • I'm not trying to set environment variables, the command is in the package.json file that was generated with yeoman – Boris Kaptsanov Aug 01 '22 at 15:41
  • `BABEL_OUTPUT=esm` **is** trying to set an environment variable, for the `babel` command that follows. – jonrsharpe Aug 01 '22 at 15:42
  • Ohhhhhh sorry. I'll check out the links right now. – Boris Kaptsanov Aug 01 '22 at 15:44

1 Answers1

0

I have observed that This error only occurs in windows, not in ubuntu To resolve this error You can modify the package.josn file script tag

 "scripts": {
    "build": "npm run build-cjs && npm run build-esm && npm run ts-types",
    "build-cjs": "babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir lib",
    "build-clean": "npm run clean && npm run build",
    "build-esm": "BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir esm",
    "dev": "BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --watch --copy-files --out-dir esm",
    "prebuild": "rimraf {lib,esm,tsconfig.tsbuildinfo}",
    "postbuild": "npm run test",
    "ts-types": "tsc --build",
    "test": "jest"
  }

TO

 "scripts": {
    "build": "npm run build-cjs && npm run build-esm && npm run ts-types",
    "build-cjs": "babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir lib",
    "build-clean": "npm run clean && npm run build",
    "build-esm": "set BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir esm",
    "dev": "set BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --watch --copy-files --out-dir esm",
    "prebuild": "rimraf {lib,esm,tsconfig.tsbuildinfo}",
    "postbuild": "npm run test",
    "ts-types": "tsc --build",
    "test": "jest"
  }

change part

"build-esm": "set BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --copy-files --out-dir esm",
"dev": "set BABEL_OUTPUT=esm babel src --extensions \".ts,.tsx,.js,.jsx\" --watch --copy-files --out-dir esm",

And then Try to build it will work.