Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare script error is ignored on install #4038

Open
milahu opened this issue Nov 25, 2021 · 3 comments
Open

prepare script error is ignored on install #4038

milahu opened this issue Nov 25, 2021 · 3 comments

Comments

@milahu
Copy link
Contributor

milahu commented Nov 25, 2021

im trying to install @snyk/graphlib
the package is broken, so the prepare script throws, but pnpm hides the error

cd $(mktemp -d)
npm init -y

# install from npm
pnpm i @snyk/graphlib # ok
ls node_modules/@snyk/graphlib/dist # No such file or directory = build failed

# install from git
pnpm i https://github.com/snyk/graphlib.git # ok
ls node_modules/@snyk/graphlib/dist # No such file or directory = build failed

# manually run prepare
cd node_modules/@snyk/graphlib
pnpm install #  ELIFECYCLE  Command failed with exit code 1.

graphlib/package.json

  "scripts": {
    "prepare": "tsc",

should be

  "scripts": {
    "prepare": "tsc --build",

and tsconfig.json is missing

similar #3756

@zkochan
Copy link
Member

zkochan commented Nov 26, 2021

The prepare script is only executed during local development. When running pnpm i @snyk/graphlib, the prepare script of @snyk/graphlib will not run.

@zkochan
Copy link
Member

zkochan commented Nov 27, 2021

pnpm i https://github.com/snyk/graphlib.git should work thought. And it seems to work on my machine. But I can see that it will not print any info in case of issues, so we can fix that.

@milahu
Copy link
Contributor Author

milahu commented Nov 27, 2021

When running pnpm i @snyk/graphlib, the prepare script of @snyk/graphlib will not run.

so its a bug in the npm package, cos the dist folder is missing

pnpm could detect this too, since package.json has

  "main": "dist/index.js",
  "files": [
    "index.d.ts",
    "dist/",
    "lib/"
  ],

... or simpler but slower: pnpm could try to require/import the package

currently, this

npm init -y
npm i @snyk/graphlib
node -e "require('@snyk/graphlib')"

will give a runtime error

Error: Cannot find module '/tmp/@snyk/graphlib/node_modules/@snyk/graphlib/dist/index.js'. Please verify that the package.json has a valid "main" entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants