I am creating a CLI package. I'm publishing to a GitHub account, and I have the .npmrc
pointing to the @myorg:registry=https://npm.pkg.github.com
. I can see the contents of the published package with npm pack <package>
, but when I try to npm install <package>
, the operation fails because it can't find the package.json
. This is because the package folder is not created in node_modules
.
I ran an npm install --verbose <package>
and all of the requests seem to succeed preceding the error.
This is the second package I have created and the first one works just fine.
Why might the package folder not be created?
This is what my package.json
looks like in the package being published.
{
"name": "@myorg/cy-membership-test-client",
"bin": {
"cy-membership-test-client": "./lib/index.js"
},
"scripts": {
"build": "tsc",
"start": "ts-node ./src/index.ts",
"patch-release": "npm version patch && npm publish && git push --follow-tags"
},
"repository": {
"type": "git",
"url": "git+https://github.com/myorg/cy-membership-test-client.git"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"owner": "myorg",
"author": "Josh Russo",
"license": "ISC",
"bugs": {
"url": "https://github.com/myorg/cy-membership-test-client/issues"
},
"homepage": "https://github.com/myorg/cy-membership-test-client#readme",
"dependencies": {
"@myorg/cy-membership-api-client": "^1.0.104",
"@myorg/cy-membership-test-client": "file:",
"command-line-args": "^6.0.0",
"cy-membership-test-client": "file:",
"dotenv": "^16.4.5",
"ts-node": "^10.9.2"
},
"devDependencies": {
"@types/node": "^22.3.0"
},
"version": "0.0.3"
}
This is what the verbose output looks like.
npm verb cli C:\Program Files\nodejs\node.exe C:\Users\jrusso\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm info using npm@9.2.0
npm info using node@v20.10.0
npm verb title npm install @myorg/cy-membership-test-client
npm verb argv "install" "--loglevel" "verbose" "@myorg/cy-membership-test-client"
npm verb logfile logs-max:10 dir:C:\Users\jrusso\AppData\Local\npm-cache\_logs\2024-09-16T19_08_22_238Z-
npm verb logfile C:\Users\jrusso\AppData\Local\npm-cache\_logs\2024-09-16T19_08_22_238Z-debug-0.log
npm verb shrinkwrap failed to load node_modules/.package-lock.json missing from node_modules: node_modules/membership-test-client-install-test
npm http fetch GET 200 https://npm.pkg.github.com/@myorg%2fcy-membership-test-client 456ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/ts-node 165ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/command-line-args 217ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@swc%2fcore 111ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@swc%2fhelpers 90ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@swc%2fwasm 100ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@types%2fnode 83ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/typescript 77ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/typical 112ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/array-back 118ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/undici-types 151ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/find-replace 181ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/arg 181ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/create-require 187ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@cspotcode%2fsource-map-support 199ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@tsconfig%2fnode16 214ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/make-error 241ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/v8-compile-cache-lib 240ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@tsconfig%2fnode14 244ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/acorn 248ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/lodash.camelcase 271ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/acorn-walk 271ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/diff 273ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/yn 284ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@tsconfig%2fnode10 313ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@tsconfig%2fnode12 329ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@jridgewell%2ftrace-mapping 100ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@jridgewell%2fresolve-uri 113ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@jridgewell%2fsourcemap-codec 118ms (cache revalidated)
npm verb stack Error: ENOENT: no such file or directory, open 'C:\temp\my-org\membership-test-client-install-test\node_modules\@myorg\cy-membership-test-client\package.json'
npm verb cwd C:\temp\my-org\membership-test-client-install-test
npm verb Windows_NT 10.0.22621
npm verb node v20.10.0
npm verb npm v9.2.0
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\temp\my-org\membership-test-client-install-test\node_modules\@myorg\cy-membership-test-client/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\temp\my-org\membership-test-client-install-test\node_modules\@myorg\cy-membership-test-client\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm verb exit -4058
npm verb unfinished npm timer reify 1726513702302
npm verb unfinished npm timer reify:loadTrees 1726513702303
npm verb code -4058
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jrusso\AppData\Local\npm-cache\_logs\2024-09-16T19_08_22_238Z-debug-0.log
This is what the npm pack
output looks like.
npm notice
npm notice 📦 @myorg/cy-membership-test-client@0.0.4
npm notice === Tarball Contents ===
npm notice 0B .env
npm notice 23B build.ps1
npm notice 2.8kB lib/index.js
npm notice 77B lib/messageTest.js
npm notice 6.2kB lib/userTests.js
npm notice 725B package.json
npm notice 80B run.ps1
npm notice 1.6kB src/index.ts
npm notice 193B src/messageTest.ts
npm notice 5.0kB src/userTests.ts
npm notice 12.3kB tsconfig.json
npm notice === Tarball Details ===
npm notice name: @myorg/cy-membership-test-client
npm notice version: 0.0.4
npm notice filename: myorg-cy-membership-test-client-0.0.4.tgz
npm notice package size: 7.3 kB
npm notice unpacked size: 29.0 kB
npm notice shasum: 2ef3f1a94b93c8ca347433cc317d3c6dd3ba97e7
npm notice integrity: sha512-wbq6+NtXgZVfK[...]XCDQIWjy5N6mA==
npm notice total files: 11
npm notice
myorg-cy-membership-test-client-0.0.4.tgz
Update 2024-09-17
I ran SysInternals Process Monitor to view the file system behavior when installing my existing package and this package. I can clearly see Node creating the node_modules
folders with the existing package. With this package none of the folders are even attempted to be created.
I found the problem. I had a dependency entry of "cy-membership-test-client": "file:",
that I had created when I was initially debugging the "bin"
symlink functionality.
I removed that and everything works perfectly.