// Code in this file should work in all conceivably runnable versions of node.
// A best effort is made to catch syntax errors to give users a good error message if they are using a node version that doesn't allow syntax we are using in other files such as private properties, etc
// Separated out for easier unit testing
module.exports=asyncprocess=>{
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
process.title='npm'
// if npm is called as "npmg" or "npm_g", then run in global mode.
constunsupportedMessage=`npm ${npmVersion} does not support Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
constbrokenMessage=`ERROR: npm ${npmVersion} is known not to run on Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
// Coverage ignored because this is only hit in very unsupported node versions and it's a best effort attempt to show something nice in those cases
// At this point we've required a few files and can be pretty sure we dont contain invalid syntax for this version of node. It's possible a lazy require would, but that's unlikely enough that it's not worth catching anymore and we attach the more important exit handlers.
// It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably. This is safe to use the logger now which we want since this will show up in the error log too.