title: How to solve ENOENT: no such file or directory, open '\package.json' with ngx-build-plus in workspace with multiple projects?
body: <p>In my workspace described below, I fail to build project/plugins' that doesn't have package.json with <a href="https://www.npmjs.com/package/ngx-build-plus" rel="nofollow noreferrer">ngx-build-plus</a>. If I change back to default builder it works perfectly ok. Workspace has following structure (most items omitted for clarity):</p>
  <pre><code>- projects
    - shared
      - src 
        - lib
          ...
      - package.json
        ...   
        
    - plugins
      - src
        - app
          ... plugin app is here
      - webpack.config.js  
  - src
    - app
    
    ... the main app is here
    
    -webpack.config.js          
  -angular.json
  -package.json
  </code></pre>
  <p>I am trying to implement angular webpack-5 module federation and I'm following example:</p>
  <p><a href="https://github.com/alexzuza/angular-plugin-architecture-with-module-federation" rel="nofollow noreferrer">https://github.com/alexzuza/angular-plugin-architecture-with-module-federation</a></p>
  <p>In the example the projects/plugins doesn't have own package.json and building it with command <strong>ng build plugins --prod</strong> works without any problem.</p>
  <p>I've imitated the example's structure with my existing app that did not have projects folder before. Building the main app is not a problem. Also building shared-library works. However trying to build plugins produces:</p>
  <pre><code>    'node-sass' usage is deprecated and will be removed in a future major version. To opt-out of the deprecated behaviour and start using 'sass' uninstall 'node-sass'.
  - Generating browser application bundles...Compiling @angular/core : es2015 as esm2015
  Compiling @angular/common : es2015 as esm2015
  Compiling shared : es2015 as esm2015
  Compiling @angular/platform-browser : es2015 as esm2015
  Compiling @angular/platform-browser-dynamic : es2015 as esm2015
  Compiling @angular/router : es2015 as esm2015
  ✔ Browser application bundle generation complete.
  An unhandled exception occurred: ENOENT: no such file or directory, open '\package.json'
  See &quot;C:\Users\char-m\AppData\Local\Temp\ng-plu2me\angular-errors.log&quot; for further details.
  npm ERR! code ELIFECYCLE
  npm ERR! syscall spawn
  npm ERR! file C:\WINDOWS\system32\cmd.exe
  npm ERR! errno ENOENT
  npm ERR! NIS@0.0.0 build:plugins: `ng build plugins --prod`
  npm ERR! spawn ENOENT
  npm ERR!
  npm ERR! Failed at the NIS@0.0.0 build:plugins script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\char-m\AppData\Roaming\npm-cache\_logs\2021-04-07T19_34_04_884Z-debug.log
  </code></pre>
  <p>Clicking '\package.json' in terminal output above opens the package.json in workspace root without a problem.</p>
  <p>Copying the package.json from the root to projects/plugins/ solves this issue. However I don't want to duplicate the file.</p>
  <p><strong>EDIT: If I update angular version to older (from 11.1.1) like this:</strong></p>
  <pre><code>Angular CLI: 11.0.7
  Node: 14.15.1
  OS: win32 x64
  
  Angular: 11.0.0
  ... animations, cdk, common, compiler, compiler-cli, core, forms
  ... material, material-moment-adapter, platform-browser
  ... platform-browser-dynamic, platform-server, router
  Ivy Workspace: Yes
  
  Package                         Version
  ---------------------------------------------------------
  @angular-devkit/architect       0.1100.7
  @angular-devkit/build-angular   0.1100.7
  @angular-devkit/core            11.0.7
  @angular-devkit/schematics      11.0.7
  @angular/cli                    11.0.7
  @angular/language-service       11.2.9
  @schematics/angular             11.0.7
  @schematics/update              0.1100.7
  ng-packagr                      11.2.4
  rxjs                            6.5.5
  typescript                      4.0.7
  webpack                         5.31.0
  </code></pre>
  <p>the build works. However this is not an option because this produces <a href="https://github.com/angular/angular-cli/issues/19550" rel="nofollow noreferrer">another bug when serving the application</a>.</p>
  <p>Any ideas how to fix this would be highly appreciated.</p>
  <p>File angular-errors.log looks like below:</p>
  <pre><code>[error] HookWebpackError: ENOENT: no such file or directory, open '\package.json'
      at makeWebpackError (C:\dev\nis\NIS\ClientApp\node_modules\webpack\lib\HookWebpackError.js:49:9)
      at C:\dev\nis\NIS\ClientApp\node_modules\webpack\lib\Compilation.js:2394:12
      at eval (eval at create (C:\dev\nis\NIS\ClientApp\node_modules\tapable\lib\HookCodeFactory.js:33:10), &lt;anonymous&gt;:31:1)
      at fn (C:\dev\nis\NIS\ClientApp\node_modules\webpack\lib\Compilation.js:376:17)
      at _next4 (eval at create (C:\dev\nis\NIS\ClientApp\node_modules\tapable\lib\HookCodeFactory.js:33:10), &lt;anonymous&gt;:28:1)
      at eval (eval at create (C:\dev\nis\NIS\ClientApp\node_modules\tapable\lib\HookCodeFactory.js:33:10), &lt;anonymous&gt;:47:1)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
  -- inner error --
  Error: ENOENT: no such file or directory, open '\package.json'
      at Object.openSync (fs.js:476:3)
      at Object.readFileSync (fs.js:377:35)
      at CacheBackend.provideSync (C:\dev\nis\NIS\ClientApp\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:233:32)
      at WebpackFileSystem.readFileAsUtf8 (C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\WebpackFileSystem.js:52:24)
      at PluginChunkReadHandler.getPackageJson (C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\PluginChunkReadHandler.js:35:43)
      at PluginChunkReadHandler.processModule (C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\PluginChunkReadHandler.js:45:40)
      at C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\PluginChunkReadHandler.js:29:23
      at WebpackModuleFileIterator.internalCallback (C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\WebpackModuleFileIterator.js:28:13)
      at WebpackModuleFileIterator.iterateFiles (C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\WebpackModuleFileIterator.js:8:9)
      at C:\dev\nis\NIS\ClientApp\node_modules\license-webpack-plugin\dist\PluginChunkReadHandler.js:27:32
  </code></pre>
  <p>File 2021-04-07T19_34_04_884Z-debug.log looks like this:</p>
  <pre><code>0 info it worked if it ends with ok
  1 verbose cli [
  1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
  1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
  1 verbose cli   'run',
  1 verbose cli   'build:plugins'
  1 verbose cli ]
  2 info using npm@6.14.8
  3 info using node@v14.15.1
  4 verbose run-script [ 'prebuild:plugins', 'build:plugins', 'postbuild:plugins' ]
  5 info lifecycle NIS@0.0.0~prebuild:plugins: NIS@0.0.0
  6 info lifecycle NIS@0.0.0~build:plugins: NIS@0.0.0
  7 verbose lifecycle NIS@0.0.0~build:plugins: unsafe-perm in lifecycle true
  8 verbose lifecycle NIS@0.0.0~build:plugins: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\dev\nis\NIS\ClientApp\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Users\char-m\AppData\Local\Microsoft\WindowsApps;;C:\Users\char-m\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\char-m\AppData\Roaming\npm;C:\Program Files\Azure Data Studio\bin;C:\Users\char-m\AppData\Local\Yarn\bin;C:\Users\char-m\.dotnet\tools
  9 verbose lifecycle NIS@0.0.0~build:plugins: CWD: C:\dev\nis\NIS\ClientApp
  10 silly lifecycle NIS@0.0.0~build:plugins: Args: [ '/d /s /c', 'ng build plugins --prod' ]
  11 info lifecycle NIS@0.0.0~build:plugins: Failed to exec build:plugins script
  12 verbose stack Error: NIS@0.0.0 build:plugins: `ng build plugins --prod`
  12 verbose stack spawn ENOENT
  12 verbose stack     at ChildProcess.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:48:18)
  12 verbose stack     at ChildProcess.emit (events.js:315:20)
  12 verbose stack     at maybeClose (internal/child_process.js:1048:16)
  12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
  13 verbose pkgid NIS@0.0.0
  14 verbose cwd C:\dev\nis\NIS\ClientApp
  15 verbose Windows_NT 10.0.18363
  16 verbose argv &quot;C:\\Program Files\\nodejs\\node.exe&quot; &quot;C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js&quot; &quot;run&quot; &quot;build:plugins&quot;
  17 verbose node v14.15.1
  18 verbose npm  v6.14.8
  19 error code ELIFECYCLE
  20 error syscall spawn
  21 error file C:\WINDOWS\system32\cmd.exe
  22 error errno ENOENT
  23 error NIS@0.0.0 build:plugins: `ng build plugins --prod`
  23 error spawn ENOENT
  24 error Failed at the NIS@0.0.0 build:plugins script.
  24 error This is probably not a problem with npm. There is likely additional logging output above.
  25 verbose exit [ 1, true ]
  </code></pre>