TypeError: Невозможно прочитать свойство split из undefined в nodejs nodemon - PullRequest
0 голосов
/ 20 апреля 2020

ошибка img

реакция / узел. js Я не знаю, в чем проблема. Это говорит о том, что их ошибка в nodemon. Но я не могу выяснить проблему. Помогите мне, пожалуйста.

index.js:4 Uncaught TypeError: Cannot read property 'split' of undefined
    at Object.<anonymous> (index.js:4)
    at Object.../node_modules/nodemon/lib/utils/index.js (index.js:95)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.<anonymous> (run.js:3)
    at Object.../node_modules/nodemon/lib/monitor/run.js (run.js:459)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.../node_modules/nodemon/lib/monitor/index.js (index.js:2)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    ...

вот код

var noop = function () { };
var path = require('path');
const semver = require('semver');
//here is the problem. There is a 'split'.
var version = process.versions.node.split('.') || [null, null, null];

var utils = (module.exports = {
  semver: semver,
  satisfies: test => semver.satisfies(process.versions.node, test),
  version: {
    major: parseInt(version[0] || 0, 10),
    minor: parseInt(version[1] || 0, 10),
    patch: parseInt(version[2] || 0, 10),
  },
  clone: require('./clone'),
  merge: require('./merge'),
  bus: require('./bus'),
  isWindows: process.platform === 'win32',
  isMac: process.platform === 'darwin',
  isLinux: process.platform === 'linux',
  isRequired: (function () {
...

1 Ответ

0 голосов
/ 20 апреля 2020

Если вы пытаетесь получить версию, go для свойства process.version вместо process.versions.

Вот как должен выглядеть process.

process {
  version: 'v12.16.2',
  versions: {
    node: '12.16.2',
    v8: '7.8.279.23-node.34',
    uv: '1.34.2',
    zlib: '1.2.11',
    brotli: '1.0.7',
    ares: '1.15.0',
    modules: '72',
    nghttp2: '1.40.0',
    napi: '5',
    llhttp: '2.0.4',
    http_parser: '2.9.3',
    openssl: '1.1.1e',
    cldr: '36.0',
    icu: '65.1',
    tz: '2019c',
    unicode: '12.1'
  },
  arch: 'x64',
  platform: 'darwin',
  release: {
    name: 'node',
    lts: 'Erbium',
    sourceUrl: 'https://nodejs.org/download/release/v12.16.2/node-v12.16.2.tar.gz',
    headersUrl: 'https://nodejs.org/download/release/v12.16.2/node-v12.16.2-headers.tar.gz'
  },

...