nx icon indicating copy to clipboard operation
nx copied to clipboard

Running any nx cli command fails with the following output: Original error: Failed to convert napi `Undefined` into rust type `String`

Open kentytik opened this issue 1 year ago • 3 comments

Current Behavior

Any nx cli command fails with the following output:

Original error: Failed to convert napi Undefined into rust type String

Error: Failed to convert napi Undefined into rust type String at nativeHashArray (/mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/hasher/impl/native-file-hasher.js:40:12) at createNode (/mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/plugins/js/lock-file/npm-parser.js:82:38) at /mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/plugins/js/lock-file/npm-parser.js:28:13 at Array.forEach () at addNodes (/mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/plugins/js/lock-file/npm-parser.js:21:39) at parseNpmLockfile (/mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/plugins/js/lock-file/npm-parser.js:14:5) at parseLockFile (/mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/plugins/js/lock-file/lock-file.js:82:47) at /mnt/usbhdd1/home/adwene/devx/node_modules/nx/src/plugins/js/index.js:24:64 at Generator.next () at /mnt/usbhdd1/home/adwene/devx/node_modules/tslib/tslib.js:167:75

NX Failed to process the project graph with "nx-js-graph-plugin".

The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

Expected Behavior

The nx cli command expected to run properly to produce the expected result

GitHub Repo

No response

Steps to Reproduce

Running any nx cli command in the workspace

Nx Report

Any cli command, including nx report, fails. However, generated this manually based on a previous 'nx report run' and updated with versions of packages from npm ls. 

Node : 18.16.0
   OS   : linux x64
   npm  : 9.6.7

   nx                      : 16.3.2
   @nx/js                : 16.3.2
   @nx/jest              : 16.3.2
   @nx/linter            : 16.3.2
   @nx/workspace         : 16.3.2
   @nx/angular           : 16.3.2
   @nx/cypress           : 16.3.2
   @nx/devkit            : 16.3.2
   @nx/eslint-plugin-nx  : 16.3.2
   @nx/express           : 16.3.2
   @nx/nest              : 16.3.2
   @nx/next              : 16.3.2
   @nx/node              : 16.3.2
   @nx/react             : 16.3.2
   @nx/rollup            : 16.3.2
   @nx/tao               : 16.3.2
   @nx/web               : 16.3.2
   @nx/webpack           : 16.3.2
   typescript              : 5.1.2
   ---------------------------------------
   Community plugins:
   @ngrx/effects               : 16.0.1
   @ngrx/router-store          : 16.0.1
   @ngrx/store                 : 16.0.1
   @nguniversal/express-engine : 16.0.2
   @ngrx/store-devtools        : 16.0.1
   @nguniversal/builders       : 16.0.2

Failure Logs

>  NX   Failed to process the project graph with "nx-js-graph-plugin".

   The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

Operating System

  • [ ] macOS
  • [X] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

package.json:


{
  "name": "devworkspace",
  "version": "0.0.0",
  "description": "",
  "private": true,
  "scripts": {
  },
  "author": "Kenty K",
  "license": "ISC",
  "workspaces": [
    "apps/**/*",
    "libs/**/*"
  ],
  "repository": {
    "type": "git",
    "url": ""
  },
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "devDependencies": {
    "@angular-devkit/build-angular": "16.0.4",
    "@angular-devkit/core": "16.0.4",
    "@angular-devkit/schematics": "16.0.4",
    "@angular-eslint/eslint-plugin": "16.0.3",
    "@angular-eslint/eslint-plugin-template": "16.0.3",
    "@angular-eslint/template-parser": "16.0.3",
    "@angular/cli": "16.0.4",
    "@angular/compiler-cli": "16.0.4",
    "@angular/language-service": "16.0.4",
    "@babel/preset-react": "7.22.3",
    "@fullhuman/postcss-purgecss": "5.0.0",
    "@nestjs/schematics": "9.2.0",
    "@nestjs/testing": "9.4.2",
    "@ngrx/store-devtools": "16.0.1",
    "@nguniversal/builders": "16.0.2",
    "@nx/js": "16.3.2",
    "@nx/linter": "16.3.2",
    "@nx/eslint-plugin": "16.3.2",
    "@nx/react": "16.3.2",
    "@nx/nest": "16.3.2",
    "@nx/node": "16.3.2",
    "@nx/next": "16.3.2",
    "@nx/cypress": "16.3.2",
    "@nx/jest": "16.3.2",
    "@nx/express": "16.3.2",
    "@nx/web": "16.3.2",
    "@nx/angular": "16.3.2",
    "@nx/webpack": "16.3.2",
    "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
    "@schematics/angular": "16.0.4",
    "@svgr/webpack": "8.0.1",
    "@testing-library/react": "14.0.0",
    "@types/bootstrap": "~5.2.6",
    "@types/express": "~4.17.17",
    "@types/jest": "~29.5.2",
    "@types/node": "~20.2.5",
    "@types/react": "~18.2.8",
    "@types/react-dom": "~18.2.4",
    "@typescript-eslint/eslint-plugin": "5.59.8",
    "@typescript-eslint/parser": "5.59.8",
    "autoprefixer": "10.4.14",
    "babel-jest": "29.5.0",
    "css-loader": "6.8.1",
    "cypress": "12.13.0",
    "eslint": "8.42.0",
    "eslint-config-next": "~13.4.4",
    "eslint-plugin-cypress": "~2.13.3",
    "eslint-plugin-import": "2.27.5",
    "eslint-plugin-jsdoc": "~46.2.3",
    "eslint-plugin-jsx-a11y": "~6.7.1",
    "eslint-plugin-react": "~7.32.2",
    "eslint-plugin-react-hooks": "~4.6.0",
    "firebase-tools": "12.3.0",
    "html-loader": "4.2.0",
    "html-webpack-plugin": "5.5.1",
    "jest": "29.5.0",
    "jest-environment-jsdom": "29.5.0",
    "jest-preset-angular": "13.1.1",
    "ng-packagr": "16.0.1",
    "npm-check-updates": "16.10.12",
    "nx": "16.3.2",
    "nx-cloud": "16.0.5",
    "postcss": "8.4.24",
    "postcss-flexbugs-fixes": "5.0.2",
    "postcss-import": "15.1.0",
    "postcss-loader": "7.3.2",
    "postcss-normalize": "10.0.1",
    "postcss-preset-env": "8.4.2",
    "postcss-sorting": "8.0.2",
    "postcss-url": "10.1.3",
    "prettier": "2.8.8",
    "sass": "1.62.1",
    "sass-loader": "13.3.1",
    "style-loader": "3.3.3",
    "ts-jest": "29.1.0",
    "ts-node": "10.9.1",
    "typescript": "5.1.3",
    "url-loader": "4.1.1",
    "webpack": "5.85.0",
    "webpack-merge": "5.9.0",
    "webpack-subresource-integrity": "5.2.0-rc.1"
  },
  "dependencies": {
    "@angular/animations": "16.0.4",
    "@angular/cdk": "16.0.3",
    "@angular/common": "16.0.4",
    "@angular/compiler": "16.0.4",
    "@angular/core": "16.0.4",
    "@angular/elements": "16.0.4",
    "@angular/fire": "7.6.1",
    "@angular/forms": "16.0.4",
    "@angular/localize": "16.0.4",
    "@angular/material": "16.0.3",
    "@angular/platform-browser": "16.0.4",
    "@angular/platform-browser-dynamic": "16.0.4",
    "@angular/platform-server": "16.0.4",
    "@angular/pwa": "16.0.4",
    "@angular/router": "16.0.4",
    "@angular/service-worker": "16.0.4",
    "@nestjs/common": "9.4.2",
    "@nestjs/platform-express": "9.4.2",
    "@ngrx/effects": "16.0.1",
    "@ngrx/router-store": "16.0.1",
    "@ngrx/store": "16.0.1",
    "@nguniversal/express-engine": "16.0.2",
    "@popperjs/core": "2.11.8",
    "bootstrap": "5.3.0",
    "bootstrap-icons": "1.10.5",
    "core-js": "3.30.2",
    "express": "4.18.2",
    "firebase": "9.22.1",
    "firebase-admin": "11.9.0",
    "firebaseui": "6.0.2",
    "gcip-iap": "1.0.1",
    "next": "13.4.4",
    "ngx-pagination": "6.0.3",
    "ngx-sortable": "2.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-is": "18.2.0",
    "react-test-renderer": "18.2.0",
    "reactfire": "4.2.2",
    "regenerator-runtime": "0.13.11",
    "rxjs": "7.8.1",
    "safevalues": "0.4.3",
    "server-only": "0.0.1",
    "sortablejs": "1.15.0",
    "tslib": "2.5.3",
    "zone.js": "0.13.0"
  },
  "overrides": {
    "@grpc/grpc-js": {
      ".": "1.8.14"
    },
    "@wessberg/ts-evaluator": {
      "ts-evaluator": "1.1.0"
    },
    "cypress": {
      "@cypress/request": {
        "qs": "6.11.2"
      }
    },
    "express": {
      "body-parser": "1.20.2"
    },
    "firebase-tools": {
      "archiver": {
        "readdir-glob": {
          "minimatch": "9.0.1"
        }
      },
      "body-parser": "1.20.2",
      "exegesis": {
        "body-parser": "1.20.2"
      },
      "glob": {
        "minimatch": "9.0.1"
      },
      "http-cache-semantics": "4.1.1",
      "superstatic": {
        "minimatch": "9.0.1"
      },
      "minimatch": ".9.0.1",
      "request": {
        "uuid": "9.0.0",
        "qs": "6.11.2"
      }
    },
    "qs": {
      ".": "6.11.2"
    },
    "uuid": {
      ".": "9.0.0"
    },
    "yaml": {
      ".": "2.3.1"
    }
  }
}


kentytik avatar Jun 04 '23 17:06 kentytik

Could you please provide a repo which has the issue or at least your package.json file?

FrozenPandaz avatar Jun 06 '23 14:06 FrozenPandaz

Could you please provide a repo which has the issue or at least your package.json file?

contents of package.json file provided in edit of issue

kentytik avatar Jun 06 '23 19:06 kentytik

By "any Nx" command what do you actually mean? The npx nx report is also an nx command at it seems to be working fine meaning the graph is successfully created.

We would need a minimal repo or the detailed scenario in order to reproduce and investigate this issue.

Based on the error it seems that version of the napi package could not be resolved and resolved field was missing. This usually happens when the lock file is broken.

The lock file that was generated for me based on your package.json does not contain napi package.

meeroslav avatar Jun 15 '23 10:06 meeroslav

I also received this error after upgrade. On windows... I rm -rf node_modules package-lock.json and reinstalled and couldn't reproduce.

> npx nx report

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

rhutchison avatar Jun 20 '23 00:06 rhutchison

Same problem here. All nx commands throw this error. Deleting node_modules and package-lock.json fixed the problem.

richardliebmann avatar Jun 23 '23 10:06 richardliebmann

Can you let me know from which version were you migrating @rhutchison and @richardliebmann?

Also, which node and npm version are you using?

meeroslav avatar Jun 23 '23 11:06 meeroslav

If anyone still encounters this issue, please send us the lock file before you delete it reinstall dependencies.

meeroslav avatar Jun 23 '23 11:06 meeroslav

The issue seems to have been resolved now after update to to 16.4.0. Nx commands now run without any errors.

kentytik avatar Jun 26 '23 10:06 kentytik

This issue seems go back in 16.5.5; switching to 16.4.0 fixes it

maint14 avatar Jul 22 '23 21:07 maint14

This issue seems go back in 16.5.5; switching to 16.4.0 fixes it

switching to 16.5.3 seems to work for me

iamrommel avatar Jul 25 '23 06:07 iamrommel

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Aug 25 '23 00:08 github-actions[bot]