Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why npm install cause Error: Cannot find module '@nx/nx-darwin-arm64' in Angular project

I'm recently cloned one Angular Project on my MacBook (M1 Pro Chip), and I want simple run npm install but I'm facing Error: Cannot find module '@nx/nx-darwin-arm64'.

This is error message what I'm receiving.

npm ERR! code 1
npm ERR! path /Users/username/projects/abc/project-name/node_modules/nx
npm ERR! command failed
npm ERR! command sh -c node ./bin/post-install
npm ERR! /Users/username/projects/abc/project-name/node_modules/nx/src/native/native-bindings.js:244
npm ERR!     throw loadError
npm ERR!     ^
npm ERR! 
npm ERR! Error: Cannot find module '@nx/nx-darwin-arm64'
npm ERR! Require stack:
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/src/native/index.js
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/src/hasher/node-task-hasher-impl.js
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/src/hasher/task-hasher.js
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/src/hasher/hash-task.js
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/src/tasks-runner/run-command.js
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/src/nx-cloud/utilities/get-cloud-options.js
npm ERR! - /Users/username/projects/abc/project-name/node_modules/nx/bin/post-install.js
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
npm ERR!     at Function.resolve (node:internal/modules/helpers:190:19)
npm ERR!     at Module._load (/Users/username/projects/abc/project-name/node_modules/nx/src/native/index.js:53:36)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1230:19)
npm ERR!     at require (node:internal/modules/helpers:179:18)
npm ERR!     at Object.<anonymous> (/Users/username/projects/abc/project-name/node_modules/nx/src/native/native-bindings.js:135:29)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1368:14)
npm ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1205:32)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:1021:12) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/src/native/index.js',
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/src/hasher/node-task-hasher-impl.js',
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/src/hasher/task-hasher.js',
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/src/hasher/hash-task.js',
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/src/tasks-runner/run-command.js',
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/src/nx-cloud/utilities/get-cloud-options.js',
npm ERR!     '/Users/username/projects/abc/project-name/node_modules/nx/bin/post-install.js'
npm ERR!   ]
npm ERR! }
npm ERR! 
npm ERR! Node.js v21.7.3

npm ERR! A complete log of this run can be found in: /Users/username/.npm/_logs/2024-06-13T15_02_04_941Z-debug-0.log

This is my package.json

{
  "name": "project-name",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^17.3.0",
    "@angular/cdk": "~17.3.5",
    "@angular/common": "^17.3.0",
    "@angular/compiler": "^17.3.0",
    "@angular/core": "^17.3.0",
    "@angular/forms": "^17.3.5",
    "@angular/localize": "^17.3.0",
    "@angular/material": "~17.3.5",
    "@angular/platform-browser": "^17.3.0",
    "@angular/platform-browser-dynamic": "^17.3.0",
    "@angular/router": "^17.3.0",
    "@ngx-formly/core": "^6.3.0",
    "@ngx-formly/kendo": "^6.3.0",
    "@progress/kendo-angular-buttons": "15.4.0",
    "@progress/kendo-angular-common": "15.4.0",
    "@progress/kendo-angular-dateinputs": "^15.4.0",
    "@progress/kendo-angular-dialog": "15.4.0",
    "@progress/kendo-angular-dropdowns": "15.4.0",
    "@progress/kendo-angular-excel-export": "15.4.0",
    "@progress/kendo-angular-grid": "^15.4.0",
    "@progress/kendo-angular-icons": "15.4.0",
    "@progress/kendo-angular-inputs": "15.4.0",
    "@progress/kendo-angular-intl": "15.4.0",
    "@progress/kendo-angular-l10n": "15.4.0",
    "@progress/kendo-angular-label": "15.4.0",
    "@progress/kendo-angular-layout": "15.4.0",
    "@progress/kendo-angular-navigation": "15.4.0",
    "@progress/kendo-angular-notification": "^15.4.0",
    "@progress/kendo-angular-pdf-export": "15.4.0",
    "@progress/kendo-angular-popup": "15.4.0",
    "@progress/kendo-angular-progressbar": "15.4.0",
    "@progress/kendo-angular-spreadsheet": "15.4.0",
    "@progress/kendo-angular-treeview": "15.4.0",
    "@progress/kendo-angular-upload": "^15.4.0",
    "@progress/kendo-angular-utils": "15.4.0",
    "@progress/kendo-data-query": "^1.0.0",
    "@progress/kendo-drawing": "^1.19.0",
    "@progress/kendo-licensing": "^1.0.2",
    "@progress/kendo-svg-icons": "^2.0.0",
    "@progress/kendo-theme-default": "^7.2.0",
    "angular-oauth2-oidc": "^17.0.2",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.3.1",
    "@angular-eslint/builder": "17.3.0",
    "@angular-eslint/eslint-plugin": "17.3.0",
    "@angular-eslint/eslint-plugin-template": "17.3.0",
    "@angular-eslint/schematics": "17.3.0",
    "@angular-eslint/template-parser": "17.3.0",
    "@angular/cli": "^17.3.1",
    "@angular/compiler-cli": "^17.3.0",
    "@ngx-formly/schematics": "^6.3.0",
    "@types/jasmine": "~5.1.0",
    "@typescript-eslint/eslint-plugin": "7.2.0",
    "@typescript-eslint/parser": "7.2.0",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.1.3",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "prettier": "^3.2.5",
    "prettier-eslint": "^16.3.0",
    "typescript": "~5.4.2"
  }
}

I already tried change machine's architecture type with:

arch -x86_64 zsh
nvm install 18.15 

node -p 'process.arch' -> x64

But unfortunately than I get: Error: Cannot find module '@nx/nx-darwin-x64'

I tried on Windows 10 machine, and I have successfully installed there with Node.js v18.15.0

like image 232
mario89 Avatar asked Oct 12 '25 01:10

mario89


1 Answers

You might want to delete your current node_modules folder and also the package-lock.json file and try npm install again. That is what tools like nx suggest to fix this type of issue (I know you do not seem to be using nx, but this looks like a similar issue).

The lock file might have being built from a different OS and might currently hold some hard references to packages versions which are not compatible with your current one.

like image 117
The Fabio Avatar answered Oct 14 '25 18:10

The Fabio