TexteaInc / json-viewer

not only a JSON viewer
https://viewer.textea.io
MIT License
459 stars 36 forks source link

cannot install via npm #104

Closed sbitenc closed 2 years ago

sbitenc commented 2 years ago

I get the following error:

npm ERR! code 1
npm ERR! path /Users/xyz/Frontend/gui/node_modules/@textea/json-viewer
npm ERR! command failed
npm ERR! command sh -c -- husky install
npm ERR! husky - .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)

Can husky be excluded from the packaged dist 🙏

himself65 commented 2 years ago

the bundled scripts are

  "scripts": {
    "test": "echo \"no tests for now\"",
    "_postinstall": "husky install",
    "prepack": "pinst --disable",
    "postpack": "pinst --enable",
    "lint": "npx eslint . --ext .ts,.tsx,.js,.jsx --cache --fix",
    "build": "tsc && vite build",
    "prepublishOnly": "npm run build"
  },

I don't think this will cause install husky

himself65 commented 2 years ago

could you please give me the full logs?

sbitenc commented 2 years ago

Hmm, where can i upload it. I'll paste the relevant last part of logs

9585 timing build:link Completed in 15ms
9586 info run fsevents@2.3.2 install node_modules/fsevents node-gyp rebuild
9587 info run fsevents@2.3.2 install { code: 1, signal: null }
9588 verbose reify failed optional dependency /Users/xyz/shigoto/Frontend/hg-orion-gui-2/node_modules/fsevents
9589 silly reify mark deleted [
9589 silly reify   '/Users/xyz/shigoto/Frontend/hg-orion-gui-2/node_modules/fsevents'
9589 silly reify ]
9590 timing build:run:install:node_modules/fsevents Completed in 477ms
9591 timing build:run:install Completed in 477ms
9592 info run @textea/json-viewer@2.9.0 postinstall node_modules/@textea/json-viewer husky install
9593 info run core-js@2.6.12 postinstall node_modules/core-js node -e "try{require('./postinstall')}catch(e){}"
9594 info run core-js-pure@3.25.5 postinstall node_modules/core-js-pure node -e "try{require('./postinstall')}catch(e){}"
9595 info run cypress@10.9.0 postinstall node_modules/cypress node index.js --exec install
9596 info run es5-ext@0.10.62 postinstall node_modules/es5-ext  node -e "try{require('./_postinstall')}catch(e){}" || exit 0
9597 info run cucumber-expressions@5.0.18 postinstall node_modules/cucumber/node_modules/cucumber-expressions node scripts/postinstall.js
9598 info run core-js@3.25.5 postinstall node_modules/react-app-polyfill/node_modules/core-js node -e "try{require('./postinstall')}catch(e){}"
9599 info run core-js-pure@3.25.5 postinstall { code: 0, signal: null }
9600 timing build:run:postinstall:node_modules/core-js-pure Completed in 101ms
9601 info run core-js@2.6.12 postinstall { code: 0, signal: null }
9602 timing build:run:postinstall:node_modules/core-js Completed in 117ms
9603 info run es5-ext@0.10.62 postinstall { code: 0, signal: null }
9604 timing build:run:postinstall:node_modules/es5-ext Completed in 64ms
9605 info run cucumber-expressions@5.0.18 postinstall { code: 0, signal: null }
9606 timing build:run:postinstall:node_modules/cucumber/node_modules/cucumber-expressions Completed in 51ms
9607 info run core-js@3.25.5 postinstall { code: 0, signal: null }
9608 timing build:run:postinstall:node_modules/react-app-polyfill/node_modules/core-js Completed in 50ms
9609 info run @textea/json-viewer@2.9.0 postinstall { code: 1, signal: null }
9610 info run cypress@10.9.0 postinstall { code: 1, signal: null }
9611 timing reify:rollback:createSparse Completed in 8296ms
9612 timing reify:rollback:retireShallow Completed in 0ms
9613 timing command:i Completed in 278575ms
9614 verbose stack Error: command failed
9614 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
9614 verbose stack     at ChildProcess.emit (node:events:513:28)
9614 verbose stack     at maybeClose (node:internal/child_process:1091:16)
9614 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
9614 verbose stack     at Socket.emit (node:events:513:28)
9614 verbose stack     at Pipe.<anonymous> (node:net:313:12)
9615 verbose pkgid @textea/json-viewer@2.9.0
9616 verbose cwd /Users/xyz/shigoto/Frontend/hg-orion-gui-2
9617 verbose Darwin 21.6.0
9618 verbose node v18.10.0
9619 verbose npm  v8.19.2
9620 error code 1
9621 error path /Users/xyz/shigoto/Frontend/hg-orion-gui-2/node_modules/@textea/json-viewer
9622 error command failed
9623 error command sh -c -- husky install
9624 error husky - .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)
9625 verbose exit 1
9626 timing npm Completed in 278635ms
9627 verbose unfinished npm timer reify 1665420364083
9628 verbose unfinished npm timer reify:build 1665420633633
9629 verbose unfinished npm timer build 1665420633634
9630 verbose unfinished npm timer build:deps 1665420633634
9631 verbose unfinished npm timer build:run:postinstall 1665420634143
9632 verbose unfinished npm timer build:run:postinstall:node_modules/@textea/json-viewer 1665420634143
9633 verbose unfinished npm timer build:run:postinstall:node_modules/cypress 1665420634190
9634 verbose code 1
9635 error A complete log of this run can be found in:
9635 error     /Users/xyz/.npm/_logs/2022-10-10T16_46_04_025Z-debug-0.log
himself65 commented 2 years ago

I believe I've removed the postinstall script before publishing. Could you please check node_modules/@textea/json-viewer, and give me the screenshot of files and details of its packages.json

sbitenc commented 2 years ago

I had to install it using npm install --ignore-scripts, otherwise i never got the node_modules

here's package json

{
  "name": "@textea/json-viewer",
  "description": "Interactive Json Viewer, but not only a json viewer",
  "version": "2.9.0",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/TexteaInc/json-viewer.git"
  },
  "author": "himself65 <himself65@outlook.com>",
  "bugs": "https://github.com/TexteaInc/json-viewer/issues",
  "homepage": "https://github.com/TexteaInc/json-viewer#readme",
  "keywords": [
    "react-18",
    "react",
    "react-json",
    "react-json-viewer",
    "array-viewer",
    "component",
    "interactive",
    "interactive-json",
    "json",
    "json-component",
    "json-display",
    "json-tree",
    "json-view",
    "json-viewer",
    "json-inspector",
    "json-tree",
    "tree",
    "tree-view",
    "treeview"
  ],
  "types": "dist/index.d.ts",
  "jsdelivr": "dist/browser.js",
  "browser": {
    "vanilla": "dist/browser.js"
  },
  "main": "dist/index.js",
  "module": "dist/index.mjs",
  "exports": {
    ".": {
      "types": "./src/type.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.js"
    }
  },
  "files": [
    "dist"
  ],
  "scripts": {
    "test": "vitest",
    "coverage": "vitest run --coverage",
    "_postinstall": "husky install",
    "prepack": "pinst --disable",
    "postpack": "pinst --enable",
    "lint": "npx eslint . --ext .ts,.tsx,.js,.jsx --cache --fix",
    "lint:ci": "npx eslint . --ext .ts,.tsx,.js,.jsx --cache",
    "build": "rollup -c rollup.config.ts --configPlugin swc3",
    "prepublishOnly": "npm run build"
  },
  "dependencies": {
    "@emotion/react": "^11.10.4",
    "@emotion/styled": "^11.10.4",
    "@mui/icons-material": "^5.10.6",
    "@mui/material": "^5.10.7",
    "copy-to-clipboard": "^3.3.2",
    "group-items": "^2.2.0",
    "zustand": "^4.1.1"
  },
  "lint-staged": {
    "!*.{ts,tsx,js,jsx}": "prettier --write --ignore-unknown",
    "*.{ts,tsx,js,jsx}": "npx eslint --cache --fix"
  },
  "peerDependencies": {
    "react": "^17 || ^18",
    "react-dom": "^17 || ^18"
  },
  "devDependencies": {
    "@commitlint/cli": "^17.1.2",
    "@commitlint/config-angular": "^17.1.0",
    "@rollup/plugin-alias": "^3.1.9",
    "@rollup/plugin-commonjs": "^22.0.2",
    "@rollup/plugin-node-resolve": "^14.1.0",
    "@rollup/plugin-replace": "^4.0.0",
    "@swc/core": "^1.3.4",
    "@testing-library/react": "^13.4.0",
    "@textea/dev-kit": "^0.13.8",
    "@types/node": "^18.7.23",
    "@types/react": "^18.0.21",
    "@types/react-dom": "^18.0.6",
    "@types/web": "^0.0.75",
    "@vitejs/plugin-react": "^2.1.0",
    "@vitest/coverage-c8": "^0.23.4",
    "@vitest/ui": "^0.23.4",
    "expect-type": "^0.14.2",
    "husky": "^8.0.1",
    "jsdom": "^20.0.1",
    "lint-staged": "^13.0.3",
    "pinst": "^3.0.0",
    "prettier": "^2.7.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "rollup": "^2.79.1",
    "rollup-plugin-dts": "^4.2.2",
    "rollup-plugin-swc3": "^0.6.0",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.4",
    "vitest": "^0.23.4"
  },
  "packageManager": "yarn@3.2.2",
  "workspaces": [
    "examples/*",
    "docs"
  ]
}
image
himself65 commented 2 years ago

maybe i know the reason, let me publish a patch after lunch

himself65 commented 2 years ago

hold on, are you using husky in your project?

sbitenc commented 2 years ago

Hi, yes, we use it for linting in the same way as your project does. Other members can install without a problem, but i'm using gitkraken and i guess it doesn't create a .git file

himself65 commented 2 years ago

Hi, yes, we use it for linting in the same way as your project does. Other members can install without a problem, but i'm using gitkraken and i guess it doesn't create a .git file

then I think might that because your configuration.

Could you re-setup husky in your project?

https://typicode.github.io/husky/#/?id=automatic-recommended

himself65 commented 2 years ago

Refs: https://github.com/typicode/husky/issues/851

sbitenc commented 2 years ago

the only code we have in our .husky is

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged

I don't know why it's calling your pre-commit command :/ Trying to re-install but it doesn't seem to be working so far. I think this is a husky issue, but i don't see why i should be running any postcompile commands here

himself65 commented 2 years ago

In my release code, there's no pre-commit command in the files

sbitenc commented 2 years ago

no clue why it wants to run: 9592 info run @textea/json-viewer@2.9.0 postinstall node_modules/@textea/json-viewer husky install :(

himself65 commented 2 years ago

let me see if there're related issues in upstream

himself65 commented 2 years ago

could you please try 2.9.1?

himself65 commented 2 years ago

I've remove all scripts field before publish it

sbitenc commented 2 years ago

I think it's not out yet

npm ERR! notarget No matching version found for @textea/json-viewer@^2.9.1.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
himself65 commented 2 years ago

npm cache clean --force

sbitenc commented 2 years ago

Aaand that worked! Thanks!