just-jeb / angular-builders

Angular build facade extensions (Jest and custom webpack configuration)
MIT License
1.15k stars 198 forks source link

Cannot find module '@angular-builders/custom-webpack/package.json' #756

Closed its-dibo closed 4 years ago

its-dibo commented 4 years ago

I'm trying to use @angular-builders/custom-webpack in an Angular9 project with Ivy enabled to use a custom webpack for server, but I got an error

An unhandled exception occurred: Cannot find module '@angular-builders/custom-webpack/package.json'
Require stack:
- node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- node_modules\@angular\cli\models\architect-command.js
- node_modules\@angular\cli\commands\run-impl.js
- node_modules\@angular-devkit\schematics\tools\export-ref.js
- node_modules\@angular-devkit\schematics\tools\index.js
- node_modules\@angular\cli\utilities\json-schema.js
- node_modules\@angular\cli\models\command-runner.js
- node_modules\@angular\cli\lib\cli\index.js
- node_modules\@angular\cli\lib\init.js
- node_modules\@angular\cli\bin\ng

angular.json

        "server": {
          "builder": "@angular-builders/custom-webpack:server",
          "options": {
            "outputPath": "dist/server",
            "main": "src/server/express.ts",
            "tsConfig": "tsconfig.server.json",
            "customWebpackConfig": { "path": "./webpack.server.config.js" }
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/env/index.ts",
                  "with": "src/env/prod.ts"
                }
              ],
              "sourceMap": false,
              "optimization": {
                "scripts": false,
                "styles": false
              }
            }
          }
        },

log file

[error] Error: Cannot find module '@angular-builders/custom-webpack/package.json'
Require stack:
- node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- node_modules\@angular\cli\models\architect-command.js
- node_modules\@angular\cli\commands\run-impl.js
- node_modules\@angular-devkit\schematics\tools\export-ref.js
- node_modules\@angular-devkit\schematics\tools\index.js
- node_modules\@angular\cli\utilities\json-schema.js
- node_modules\@angular\cli\models\command-runner.js
- node_modules\@angular\cli\lib\cli\index.js
- node_modules\@angular\cli\lib\init.js
- node_modules\@angular\cli\bin\ng
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.resolve (internal/modules/cjs/helpers.js:83:19)
    at WorkspaceNodeModulesArchitectHost.resolveBuilder (node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:41:41)
    at RunCommand.runSingleTarget (node_modules\@angular\cli\models\architect-command.js:175:55)
    at async RunCommand.runArchitectTarget (node_modules\@angular\cli\models\architect-command.js:217:24)
just-jeb commented 4 years ago

Do you have a repository with reproduction? If not, can you please create one?

its-dibo commented 4 years ago

here it is https://github.com/goblins-tech/almogtama3

please wait untill I try to run npm clean cache and reinstall it again, I will tell you if this didn't help.

@just-jeb

its-dibo commented 4 years ago

I confirm the issue solved by cleaning the npm cache and reinstall the package again