如何告诉package.json在子文件夹中查找以构建应用程序

时间:2016-10-02 16:17:51

标签: node.js reactjs heroku package

我创建了#34; create-react-app"在一个名为client的子文件夹中。我的package.json必须在根目录中(heroku)。

这是结构:

  - app
    - client
      - node_modules
      - index.js
      - components
    - ...
    - package.json
    - Procfile

这是我的package.json文件:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:3001/",
  "devDependencies": {
    "react-scripts": "0.6.1"
  },
  "dependencies": {
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-react": "^6.11.1",
    "firebase": "^3.4.1",
    "jquery": "^3.1.1",
    "react": "^15.3.2",
    "react-dom": "^15.3.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

如何告诉package.json在客户端子文件夹中查找应用程序并在那里构建它?

1 个答案:

答案 0 :(得分:1)

您可以像这样设置NODE_PATH环境变量:

export NODE_PATH=path/to/app/node_modules

您可以在官方文档中找到有关它的更多信息: https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders