Open spl opened 4 years ago
I'm doing npm install require-self && require-self in prepare step to solve this, but agree this is a bad solution.
This would all be simplified and be better if npm had a "run-after-local-npm-install" script that would do what it says and not run for publish and whatever else. Might be worth opening an issue in npm repo to discuss it ?
On Fri, Jun 26, 2020, 09:54 Sean Leather notifications@github.com wrote:
Thanks for this package! It serves a useful niche purpose.
I just wanted to discuss the proper usage. I'm rather new to the JavaScript/Node.js world, so I welcome any constructive feedback.
The README.md says to use require-self in the prepare script in the package.json:
"devDependencies": { "require-self": "^0.2.3" },"scripts": { "prepare": "require-self" }
After that, I used the setup-node https://github.com/actions/setup-node GitHub Action to publish my package https://github.com/stoicism-compendium/retext-spell-file to the npmjs registry. When I did, I ran into this problem https://github.com/stoicism-compendium/retext-spell-file/runs/808817031?check_suite_focus=true :
npm publish shell: /bin/bash -e {0} env: NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc NODE_AUTH_TOKEN: ***
retext-spell-file@0.0.2 prepare .> require-self
sh: 1: require-self: not found
On reflection, I guess this error makes sense. But then it seems like using require-self in the prepare script would require running npm install before npm publish to make sure require-self is found. It didn't seem like npm install should be necessary at the point.
Is my understanding correct? Is it typical to run npm install just before npm publish, or is that a situation created by the thing that require-self does?
As an aside, my current solution is to not have require-self in the prepare script but to run it directly after npm install and before npm test (stoicism-compendium/retext-spell-file#20 https://github.com/stoicism-compendium/retext-spell-file/pull/20).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yortus/require-self/issues/15, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437VY43TVLMSOHVOP2S3RYRH2LANCNFSM4OJCW7DA .
I'm doing npm install require-self && require-self in prepare step to solve this, but agree this is a bad solution.
@rom1504 That approach does seem like a reasonable alternative. Thanks for the comment!
I'm open to ideas here if there's a better way than what the current README suggests.
FYI previous related discussion: https://github.com/yortus/require-self/issues/9
Thanks for this package! It serves a useful niche purpose.
I just wanted to discuss the proper usage. I'm rather new to the JavaScript/Node.js world, so I welcome any constructive feedback.
The
README.md
says to userequire-self
in theprepare
script in thepackage.json
:After that, I used the
setup-node
GitHub Action to publish my package to the npmjs registry. When I did, I ran into this problem:On reflection, I guess this error makes sense. But then it seems like using
require-self
in theprepare
script would require runningnpm install
beforenpm publish
to make surerequire-self
is found. It doesn't seem likenpm install
should be necessary at that point.Is my understanding correct? Is it typical to run
npm install
just beforenpm publish
, or is that a situation created by the thing thatrequire-self
does?As an aside, my current solution is to not have
require-self
in theprepare
script but to run it directly afternpm install
and beforenpm test
in CI (https://github.com/stoicism-compendium/retext-spell-file/pull/20).