angular 16 app fails to start with 'ng s' after "npm ci"

45 views Asked by At

I have Angular 16 app, and its package.json looks like following:

  "dependencies": {
    "@angular/animations": "^16.2.12",
    "@angular/cdk": "~16.2.11",
    "@angular/common": "^16.2.12",
    "@angular/compiler": "^16.2.12",
    "@angular/core": "^16.2.12",
    "@angular/forms": "^16.2.12",
    "@angular/platform-browser": "^16.2.12",
    "@angular/platform-browser-dynamic": "^16.2.12",
    "@angular/router": "^16.2.12",
    .....
  }
  "devDependencies": {
    "@angular-devkit/build-angular": "~16.2.6",
    "@angular/cli": "~16.2.6",
    "@angular/compiler-cli": "~16.2.9",
    "@angular/language-service": "~16.2.9",
    ....
  }

After I do: "npm i" and then run "ng s", everything is fine. but then if I do "npm ci", and then "ng s", it gives me following error:

**Generating browser application bundles (phase: building)...file:///Users/xxx/ng16-app/node_modules/pkg-dir/node_modules/find-up/index.js:3 import {locatePath, locatePathSync} from 'locate-path'; ^^^^^^^^^^ SyntaxError: Named export 'locatePath' not found. The requested module 'locate-path' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'locate-path'; const {locatePath, locatePathSync} = pkg;

at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:429:15)**

I tried to see which NPM package has "locate-path" dependency by running "npm ls locate-path", and here is the result: ├─┬ @angular-devkit/[email protected] │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] I have tried to override either find-up or 'locate-path' with lower version, but neither works. Any suggestions will be greatly appreciated.

I have tried to override either find-up or 'locate-path' with lower version, but neither works.

0

There are 0 answers