Ask Your Question
1

How can I relocate the node_modules directory from within the Angular project?

asked 2021-12-02 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-03-27 21:00:00 +0000

pufferfish gravatar image

To relocate the node_modules directory from within the Angular project, you can follow these steps:

  1. Open the angular.json file in the root directory of your project.
  2. Locate the "build" configuration for your project.
  3. Add a new "options" property to the "build" configuration.
  4. Within the "options" property, add a "outputPath" property with the new location for the node_modules directory.
  5. Save and close the angular.json file.

Here is an example of what your "build" configuration should look like:

"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
    "outputPath": "../node_modules/my-project"
  },
  "configurations": {
    "production": {
      "fileReplacements": [
        {
          "replace": "src/environments/environment.ts",
          "with": "src/environments/environment.prod.ts"
        }
      ],
      "optimization": true,
      "outputHashing": "all",
      "sourceMap": false,
      "extractCss": true,
      "namedChunks": false,
      "aot": true,
      "extractLicenses": true,
      "vendorChunk": false,
      "buildOptimizer": true
    }
  }
}

In this example, the nodemodules directory will be relocated to the ../nodemodules/my-project directory, which is one level above the root directory of the Angular project. You can replace this path with any directory path that you prefer.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-12-02 11:00:00 +0000

Seen: 17 times

Last updated: Mar 27 '23