如何在Lerna monorepo上运行babel-node?

时间:2018-03-19 21:21:42

标签: javascript node.js babel lerna

我正在使用Lerna构建我的第一个monorepo。

我的lerna.json:

{
  "lerna": "2.9.0",
  "npmClient": "yarn",
  "useWorkspaces": true,
  "packages": [
    "packages/*"
  ]
}

lerna package.json就像:

{
    "name": "monorepo",
    "version": "1.0.0",
    "workspaces": [
        "packages/*"
    ],
    "private": true,
    "scripts": {
        "start": "lerna exec -- start",
        "server": "lerna exec -scope @monorepo/server -- server"
    },
    "devDependencies": {
        "lerna": "^2.9.0"
    }
}

我的项目有以下package.json:

{
  "name": "@monorepo/server",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "concurrently \"babel-node start-server\" \"babel-node start-auth-client\" \"babel-node start-editor-client\"",
    "server": "nodemon --exec \"babel-node start-server.js\"",
    "lint": "eslint ."
  },
  "dependencies": {
    "@babel/cli": "^6.24.1",
    "@babel/core": "^6.25.0",
    "@babel/plugin-transform-runtime": "^6.23.0",
    "@babel/preset-env": "^1.6.1",
    "@babel/preset-es2017": "^6.24.1",
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.17.2",
    "connect-mongo": "^2.0.0",
    "crypto": "^1.0.1",
    "express": "^4.15.3",
    "express-graphql": "^0.6.12",
    "graphql": "^0.13.1",
    "graphql-relay": "^0.5.4",
    "jwt-simple": "^0.5.1",
    "mongoose": "^5.0.10",
    "morgan": "^1.8.2",
    "nodemailer": "^4.6.0",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "path": "^0.12.7",
    "validator": "^9.1.1"
  },
  "devDependencies": {
    "concurrently": "3.5.1",
    "eslint": "^4.18.2",
    "eslint-config-airbnb": "16.1.0",
    "eslint-plugin-import": "2.9.0",
    "eslint-plugin-jsx-a11y": "6.0.3",
    "eslint-plugin-react": "7.7.0",
    "fs-extra": "^5.0.0",
    "node-fetch": "^2.1.1",
    "nodemon": "^1.11.0"
  },
  "babel": {
    "presets": [
      "@babel/es2017",
      "@babel/preset-env"
    ],
    "plugins": [
      "transform-runtime"
    ]
  }
}

我的问题是运行服务器应用程序,发出以下命令之一:

$ yarn start
yarn run v1.5.1
$ concurrently "babel-node start-server" "babel-node start-auth-client" "babel-node start-editor-client"
[0] 'babel-node' Program is not recognized as an internal or external command, operable program or batch file.
[1] 'babel-node' Program is not recognized as an internal or external command, operable program or batch file.
[2] 'babel-node' Program is not recognized as an internal or external command, operable program or batch file.
[2] babel-node start-editor-client exited with code 1
[1] babel-node start-auth-client exited with code 1
[0] babel-node start-server exited with code 1
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: C:\\WINDOWS\\system32\\cmd.exe
Arguments: /d /s /c concurrently \"babel-node start-server\" \"babel-node start-auth-client\" \"babel-node start-editor-client\"
Directory: c:\\dev\\monorepo\\packages\\server
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "c:\\dev\\monorepo\\packages\\server\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我认为这是因为所有软件包现在都位于软件包root / node_modules。

任何想法如何解决?

0 个答案:

没有答案