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

[bug] can't read package.json in postinstall.js #112

Open
tjx666 opened this issue May 9, 2024 · 0 comments
Open

[bug] can't read package.json in postinstall.js #112

tjx666 opened this issue May 9, 2024 · 0 comments

Comments

@tjx666
Copy link

tjx666 commented May 9, 2024

error message:

 error /layers/google.nodejs.yarn/yarn_modules/node_modules/simple-git-hooks: Command failed.
Step #2 - "build": Exit code: 1
Step #2 - "build": Command: node ./postinstall.js
Step #2 - "build": Arguments: 
Step #2 - "build": Directory: /layers/google.nodejs.yarn/yarn_modules/node_modules/simple-git-hooks
Step #2 - "build": Output:
Step #2 - "build": node:internal/fs/utils:356
Step #2 - "build":     throw err;
Step #2 - "build":     ^
Step #2 - "build": 
Step #2 - "build": Error: ENOENT: no such file or directory, stat '/layers/google.nodejs.yarn/yarn_modules/package.json'
Step #2 - "build":     at Object.statSync (node:fs:1688:3)
Step #2 - "build":     at _getPackageJson (/layers/google.nodejs.yarn/yarn_modules/node_modules/simple-git-hooks/simple-git-hooks.js:139:13)
Step #2 - "build":     at checkSimpleGitHooksInDependencies (/layers/google.nodejs.yarn/yarn_modules/node_modules/simple-git-hooks/simple-git-hooks.js:80:9)
Step #2 - "build":     at postinstall (/layers/google.nodejs.yarn/yarn_modules/node_modules/simple-git-hooks/postinstall.js:11:9)
Step #2 - "build":     at Object.<anonymous> (/layers/google.nodejs.yarn/yarn_modules/node_modules/simple-git-hooks/postinstall.js:19:1)
Step #2 - "build":     at Module._compile (node:internal/modules/cjs/loader:1364:14)
Step #2 - "build":     at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
Step #2 - "build":     at Module.load (node:internal/modules/cjs/loader:1203:32)
Step #2 - "build":     at Module._load (node:internal/modules/cjs/loader:1019:12)
Step #2 - "build":     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
Step #2 - "build":   errno: -2,
Step #2 - "build":   syscall: 'stat',
Step #2 - "build":   code: 'ENOENT',
Step #2 - "build":   path: '/layers/google.nodejs.yarn/yarn_modules/package.json'
Step #2 - "build": }
Step #2 - "build": 

expect:

don't do anything when package.json not exists in project

What's more

I think the postinstall.js should just skip when find self install in CI environment. You can use https://www.npmjs.com/package/ci-info

@tjx666 tjx666 changed the title [bug] can't red package.json in postinstall.js [bug] can't read package.json in postinstall.js May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant