Windows 中ts-node命令SyntaxError报错的问题

报错信息类似于:

> npm run config-local && ng serve --configuration local --port 4201


> [email protected] config-local
> ts-node -O '{"module": "commonjs"}' ./scripts/env.config.ts local

undefined:1
'{module:
^

SyntaxError: Unexpected token ' in JSON at position 0

------------


我的package.json 配置是:

ts-node -O '{\"module\": \"commonjs\"}' ./scripts/env.config.ts local

这样在cmd 报错:SyntaxError: Unexpected token \ in JSON at position 1

  1. 创建一个名为 aa.json(或任何其他名称)的文件,内容如下:
{
  "compilerOptions": {
    "module": "commonjs"
  }
}

之前的配置修改为:

"build-local-env": "ts-node --project aa.json  ./scripts/env.config.ts local",

猜你喜欢

转载自blog.csdn.net/qq_36279445/article/details/131681323