Open ctjlewis opened 3 years ago
@ctjlewis Have you tried using the .cjs
extension? I was having the same problem but I was able to get things working by changing the package-scripts.js
file to package-scripts.cjs
and then calling nps
with the command:
nps -c ./package-scripts.cjs
Definitely not as simple as just typing nps
of course, but I aliased the above in my bash profile and that's at least a workable answer (for me).
I have similar problem, also the old project that use nps. But in my case nps run other nps scripts and nps -c ./package-scripts.cjs
doesn't work because nested nps are no invoked I've got error that no config get found. Only top level nps is executed.
You have a few options:
package-scripts.yaml
.npmrc.json
with the following config and rename package-scripts.js
to package-scripts.cjs
{
"config": "./package-scripts.cjs"
}
I use the .cjs
option.
Sadly, I have the great misfortune of needing to work on a codebase which uses
nps
, and despite the project's stated goal, "unmaintainable mess" is quite an understatement due to the number of security vulnerabilities and CJS/ESM conflicts I'm getting.Is there any way for me to load
package-scripts.js
in an ESM context? It seems likenps
is just trying to naivelyrequire(...)
the module without checking for mjs extension, sonps -c ./package-scripts.mjs
throwsERR_REQUIRE_ESM
.