惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Vercel News
Vercel News
F
Fortinet All Blogs
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
U
Unit 42
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
MongoDB | Blog
MongoDB | Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
S
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
Attack and Defense Labs
Attack and Defense Labs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LangChain Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hacker News: Ask HN
Hacker News: Ask HN
Jina AI
Jina AI
Schneier on Security
Schneier on Security
W
WeLiveSecurity
Microsoft Security Blog
Microsoft Security Blog
博客园_首页
博客园 - 聂微东

博客园 - anonymous007

博文阅读密码验证 - 博客园 GraphQL.js All In One 2022 FIFA 世界杯决赛对阵组件库 All In One 2022 FIFA 世界杯 首发阵容组件库 All In One js 字符串转数组,数组解构默认值 All In One js sort array by date string All In One 《走遍美国》经典英语学习视频 All In One Error: EISDIR: illegal operation on a directory, read sheep match disappear game All In One 博文阅读密码验证 - 博客园 博文阅读密码验证 - 博客园 nrm & npm config All In One Next.js 13 All In One 博文阅读密码验证 - 博客园 Yarn 2.x 升级迁移指南 All In One MongoDB Database Tools All In One 支付宝小程序上线发布流程 All In One 微信小程序上线发布流程 All In One 博文阅读密码验证 - 博客园
node.js & npm version not match bug All In One
anonymous007 · 2022-11-16 · via 博客园 - anonymous007

node.js & npm version not match bug All In One

image

bug ❌

$ npm i -g npm

$ npm update -g npm
npm WARN npm npm does not support Node.js v18.12.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11, 12, 13.
npm WARN npm You can find the latest version at https://nodejs.org/
# /usr/local/bin/node ❌ 全局安装的 node.JS 已经删除了, 使用 nvm 了
➜  ~ which node
/Users/xgqfrms-mm/.nvm/versions/node/v18.12.0/bin/node
➜  ~ which npm
/usr/local/bin/npm
➜  ~ which npx
/usr/local/bin/npx

solution

删除

$ cd /usr/local/bin/

# bin 
$ ls 
bower          create-egg     slimrb         tsserver       yarnpkg
brew           gulp           taro           vue
browser-sync   npm            tilt           windscribe-cli
code           npx            tsc            yarn


# 打开 vscode
$ code .
# or, 打开 finder
$ open .


$ rm -f npm
$ rm -f npx

# npm 自动 match 使用 nvm 安装的 node.js 版本 ✅
$ which npm
/Users/xgqfrms-mm/.nvm/versions/node/v18.12.0/bin/npm
$ which npx
/Users/xgqfrms-mm/.nvm/versions/node/v18.12.0/bin/npx

$ npm -v
8.19.2
$ npx -v
8.19.2
$ node -v
v18.12.0

image

npm

#!/usr/bin/env node
;(function () { // wrapper in case we're in module_context mode
  // windows: running "npm blah" in this folder will invoke WSH, not node.
  /* global WScript */
  if (typeof WScript !== 'undefined') {
    WScript.echo(
      'npm does not work when run\n' +
        'with the Windows Scripting Host\n\n' +
        "'cd' to a different directory,\n" +
        "or type 'npm.cmd <args>',\n" +
        "or type 'node npm <args>'."
    )
    WScript.quit(1)
    return
  }

  process.title = 'npm'

  var unsupported = require('../lib/utils/unsupported.js')
  unsupported.checkForBrokenNode()

  var log = require('npmlog')
  log.pause() // will be unpaused when config is loaded.
  log.info('it worked if it ends with', 'ok')

  unsupported.checkForUnsupportedNode()

  var npm = require('../lib/npm.js')
  var npmconf = require('../lib/config/core.js')
  var errorHandler = require('../lib/utils/error-handler.js')

  var configDefs = npmconf.defs
  var shorthands = configDefs.shorthands
  var types = configDefs.types
  var nopt = require('nopt')

  // if npm is called as "npmg" or "npm_g", then
  // run in global mode.
  if (process.argv[1][process.argv[1].length - 1] === 'g') {
    process.argv.splice(1, 1, 'npm', '-g')
  }

  log.verbose('cli', process.argv)

  var conf = nopt(types, shorthands)
  npm.argv = conf.argv.remain
  if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
  else conf.usage = true

  if (conf.version) {
    console.log(npm.version)
    return errorHandler.exit(0)
  }

  if (conf.versions) {
    npm.command = 'version'
    conf.usage = false
    npm.argv = []
  }

  log.info('using', 'npm@%s', npm.version)
  log.info('using', 'node@%s', process.version)

  process.on('uncaughtException', errorHandler)
  process.on('unhandledRejection', errorHandler)

  if (conf.usage && npm.command !== 'help') {
    npm.argv.unshift(npm.command)
    npm.command = 'help'
  }

  var isGlobalNpmUpdate = conf.global && ['install', 'update'].includes(npm.command) && npm.argv.includes('npm')

  // now actually fire up npm and run the command.
  // this is how to use npm programmatically:
  conf._exit = true
  npm.load(conf, function (er) {
    if (er) return errorHandler(er)
    if (
      !isGlobalNpmUpdate &&
      npm.config.get('update-notifier') &&
      !unsupported.checkVersion(process.version).unsupported
    ) {
      const pkg = require('../package.json')
      let notifier = require('update-notifier')({pkg})
      const isCI = require('ci-info').isCI
      if (
        notifier.update &&
        notifier.update.latest !== pkg.version &&
        !isCI
      ) {
        const color = require('ansicolors')
        const useColor = npm.config.get('color')
        const useUnicode = npm.config.get('unicode')
        const old = notifier.update.current
        const latest = notifier.update.latest
        let type = notifier.update.type
        if (useColor) {
          switch (type) {
            case 'major':
              type = color.red(type)
              break
            case 'minor':
              type = color.yellow(type)
              break
            case 'patch':
              type = color.green(type)
              break
          }
        }
        const changelog = `https://github.com/npm/cli/releases/tag/v${latest}`
        notifier.notify({
          message: `New ${type} version of ${pkg.name} available! ${
            useColor ? color.red(old) : old
          } ${useUnicode ? '→' : '->'} ${
            useColor ? color.green(latest) : latest
          }\n` +
          `${
            useColor ? color.yellow('Changelog:') : 'Changelog:'
          } ${
            useColor ? color.cyan(changelog) : changelog
          }\n` +
          `Run ${
            useColor
              ? color.green(`npm install -g ${pkg.name}`)
              : `npm i -g ${pkg.name}`
          } to update!`
        })
      }
    }
    npm.commands[npm.command](npm.argv, function (err) {
      // https://genius.com/Lin-manuel-miranda-your-obedient-servant-lyrics
      if (
        !err &&
        npm.config.get('ham-it-up') &&
        !npm.config.get('json') &&
        !npm.config.get('parseable') &&
        npm.command !== 'completion'
      ) {
        console.error(
          `\n ${
            npm.config.get('unicode') ? '🎵 ' : ''
          } I Have the Honour to Be Your Obedient Servant,${
            npm.config.get('unicode') ? '🎵 ' : ''
          } ~ npm ${
            npm.config.get('unicode') ? '📜🖋 ' : ''
          }\n`
        )
      }
      errorHandler.apply(this, arguments)
    })
  })
})()


npx

#!/usr/bin/env node

const npx = require('libnpx')
const path = require('path')

const NPM_PATH = path.join(__dirname, 'npm-cli.js')

npx(npx.parseArgs(process.argv, NPM_PATH))


https://github.com/web-full-stack/nextjs-ssr/issues/7

refs


Flag Counter


©xgqfrms 2012-2020

www.cnblogs.com/anonymous007 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️anonymous007, 禁止转载 🈲️,侵权必究⚠️!