Skip to content

[BUG] npm ERR! Cannot read properties of null (reading 'package') #4787

Description

@arimus

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I do an initial npm install, which works fine. Subsequent runs result in the error:

...
111 timing command:i Completed in 1071ms
112 verbose stack TypeError: Cannot read properties of null (reading 'package')
112 verbose stack     at Link.set root [as root] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:718:35)
112 verbose stack     at Link.replace (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1155:17)
112 verbose stack     at PlaceDep.replaceOldDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:426:17)
112 verbose stack     at PlaceDep.placeInTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:304:12)
112 verbose stack     at PlaceDep.place (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:214:10)
112 verbose stack     at new PlaceDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:71:10)
112 verbose stack     at /Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:31
112 verbose stack     at Array.map (<anonymous>)
112 verbose stack     at Arborist.[buildDepStep] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:8)
112 verbose stack     at async Arborist.buildIdealTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:216:7)
113 verbose cwd /Users/arimus/workspace/appbuilder-backend

Expected Behavior

npm install not failing with the above error.

Steps To Reproduce

Environment
Starting with NPM v8.6.0 (8.5.5 does not have this issue)

Config
A package.json with a tgz file dependency. Example:

{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "license": "",
  "repository": {
    "url": "http://github.com:arimus/test.git"
  },
  "author": "arimus",
  "scripts": {
    "tsc": "tsc --project tsconfig.json",
    "start": "node ./dist/index.js",
  },
  "dependencies": {
    "apollo-server-hapi": "./apollo-server-hapi-3.5.1.tgz"
  }
}

Run

npm i

Error

...
111 timing command:i Completed in 1071ms
112 verbose stack TypeError: Cannot read properties of null (reading 'package')
112 verbose stack     at Link.set root [as root] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:718:35)
112 verbose stack     at Link.replace (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1155:17)
112 verbose stack     at PlaceDep.replaceOldDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:426:17)
112 verbose stack     at PlaceDep.placeInTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:304:12)
112 verbose stack     at PlaceDep.place (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:214:10)
112 verbose stack     at new PlaceDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:71:10)
112 verbose stack     at /Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:31
112 verbose stack     at Array.map (<anonymous>)
112 verbose stack     at Arborist.[buildDepStep] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:8)
112 verbose stack     at async Arborist.buildIdealTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:216:7)
113 verbose cwd /Users/arimus/workspace/appbuilder-backend

Environment

  • npm: 8.6.0+
  • Node.js: v16.13.1
  • OS Name: OSX
  • npm config:
; node bin location = /Users/arimus/.nvm/versions/node/v16.13.1/bin/node
; cwd = /Users/arimus/workspace/appbuilder-backend
; HOME = /Users/arimus
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 1high priority issueRelease 10.xRelease 8.xwork is associated with a specific npm 8 releaseRelease 9.xwork is associated with a specific npm 9 release

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions