question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`npm-lifecycle` dependency is deprecated

See original GitHub issue

https://github.com/ghiscoding/lerna-lite/blob/faf9b0895f19e7d39d7021a3fca76007e6b5a279/packages/core/package.json#L58

This package is deprecated: https://github.com/npm/npm-lifecycle#note-pending-imminent-deprecation

It requires node-gyp: ^5.0.2 which required request: 2.88.0 which is deprecated as well and throwing warnings.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
carbontwelvecommented, May 11, 2022

I’m planning on pulling down this repo tonight to see if I can shed some light on this and towards a valid solution.

2reactions
ghiscodingcommented, Apr 11, 2022

this seems to be the same as Lerna issue #2987 and no one ever contributed a fix. I tried to take a look at it and I don’t understand how to replace it, some options seems to be gone and some have different names and so it’s quite confusing and I cannot do it myself. So if someone can fix it through a PR, that would be great or else it would probably stay as it is.

Basically the code used by Lerna is the following

return runScript(pkg, stage, dir, {
    config,
    dir,
    failOk: false,
    log: opts.log,
    // bring along camelCased aliases
    nodeOptions: opts.nodeOptions,
    scriptShell: opts.scriptShell,
    scriptsPrependNodePath: opts.scriptsPrependNodePath,
    unsafePerm: opts.unsafePerm,
  }).then(
    () => {
      opts.log.silly('lifecycle', '%j finished in %j', stage, pkg.name);
    },
    (err: any) => {
      // propagate the exit code
      const exitCode = err.errno || 1;

      // error logging has already occurred on stderr, but we need to stop the chain
      log.error('lifecycle', '%j errored in %j, exiting %d', stage, pkg.name, exitCode);

      // ensure clean logging, avoiding spurious log dump
      err.name = 'ValidationError';

      // our yargs.fail() handler expects a numeric .exitCode, not .errno
      err.exitCode = exitCode;
      process.exitCode = exitCode;

      // stop the chain
      throw err;
    }
  );

while the new run-script is the following

const runScript = require('@npmcli/run-script')

runScript({
  // required, the script to run
  event: 'install',

  // extra args to pass to the command, defaults to []
  args: [],

  // required, the folder where the package lives
  path: '/path/to/package/folder',

  // optional, defaults to /bin/sh on unix, or cmd.exe on windows
  scriptShell: '/bin/bash',

  // optional, defaults to false
  // return stdout and stderr as strings rather than buffers
  stdioString: true,

  // optional, additional environment variables to add
  // note that process.env IS inherited by default
  // Always set:
  // - npm_package_json The package.json file in the folder
  // - npm_lifecycle_event The event that this is being run for
  // - npm_lifecycle_script The script being run
  // The fields described in https://github.com/npm/rfcs/pull/183
  env: {
    npm_package_from: 'foo@bar',
    npm_package_resolved: 'https://registry.npmjs.org/foo/-/foo-1.2.3.tgz',
    npm_package_integrity: 'sha512-foobarbaz',
  },

  // defaults to 'pipe'.  Can also pass an array like you would to node's
  // exec or spawn functions.  Note that if it's anything other than
  // 'pipe' then the stdout/stderr values on the result will be missing.
  // npm cli sets this to 'inherit' for explicit run-scripts (test, etc.)
  // but leaves it as 'pipe' for install scripts that run in parallel.
  stdio: 'inherit',

  // print the package id and script, and the command to be run, like:
  // > somepackage@1.2.3 postinstall
  // > make all-the-things
  // Defaults true when stdio:'inherit', otherwise suppressed
  banner: true,
})
  .then(({ code, signal, stdout, stderr, pkgid, path, event, script }) => {
    // do something with the results
  })
  .catch(er => {
    // command did not work.
    // er is decorated with:
    // - code
    // - signal
    // - stdout
    // - stderr
    // - path
    // - pkgid (name@version string)
    // - event
    // - script
  })

there seems to be a lot of changes between the 2, I mean it’s not clear what is what and what is dropped. If someone can shed some light that would be great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scripts - npm Docs
The dependencies script is run any time an npm command causes changes to the node_modules directory. It is run AFTER the changes have...
Read more >
Lerna >> lerna/run-lifecycle >> npm-lifecycle >> node-gyp ...
As announced by the request package maintainer, it is now fully deprecated. I noticed that it is an indirect dependency of lerna following ......
Read more >
Lifecycle - Android Developers
The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.
Read more >
NPM warn message about deprecated package - Stack Overflow
This command will analyze installed NPM-packages and their versions. The report will contain: package name; latest version; current version; dependency path ( ...
Read more >
Deprecated APIs and features - Angular
Sometimes, APIs and features become obsolete and need to be removed or replaced so that Angular can stay current with new best practices,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found