Npm исправить ошибки

Углубляюсь в язык javaScript и стал пытаться сделать что-то свое на electron.
Исходя из того что я новичок, я стал устанавливать все без разбора, пытаясь понять как все работает.
Когда понял, что мне ничего не светит, решил переустановить Node js и разобраться, что это за монстр такой.

Мое поэтапное исследование началось, ввел:

1. git clone https://github.com/electron/electron-quick-start
2. cd electron-quick-start
3. npm install
4. npm start

Первые 2 прошли испытания успешно. С 3-м и 4-м начались проблемы…

«npm install» вроде как ничего красненьким не пометил, значит ошибки нет, но все равно выложу сюда.
«npm start» тут то и началась вся канитель, от которой я хочу избавиться и начать нормально использовать electron или хоть что, чтобы хоть что-то сделать.

npm instal, вроде все топ.
5e6aa0f47523f610872871.png

Собственно сама ошибка:
5e6aa10f615e5089099351.png

Логи так-же прилагаю

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.13.7
3 info using node@v13.11.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle electron-quick-start@1.0.0~prestart: electron-quick-start@1.0.0
6 info lifecycle electron-quick-start@1.0.0~start: electron-quick-start@1.0.0
7 verbose lifecycle electron-quick-start@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle electron-quick-start@1.0.0~start: PATH: C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;E:ПрограммированиеScriptJsWorkspaseMyProgrammelectron-quick-startnode_modules.bin;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesGitcmd;e:флутерflutterbin;c:UsersSergeySaltanovichAppDataLocalAndroidSdk\tools;c:Program FilesJavajdk-13.0.2bin;c:UsersSergeySaltanovichAppDataLocalAndroidSdkplatform-tools;c:UsersSergeySaltanovichAndroidStudioProjectsflutter_applibmain.dart;C:Program Filesnodejs;;C:UsersSergeySaltanovichAppDataLocalProgramsMicrosoft VS Codebin;C:UsersSergeySaltanovichAppDataRoamingnpm
9 verbose lifecycle electron-quick-start@1.0.0~start: CWD: E:ПрограммированиеScriptJsWorkspaseMyProgrammelectron-quick-start
10 silly lifecycle electron-quick-start@1.0.0~start: Args: [ '/d /s /c', 'electron .' ]
11 silly lifecycle electron-quick-start@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle electron-quick-start@1.0.0~start: Failed to exec start script
13 verbose stack Error: electron-quick-start@1.0.0 start: `electron .`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecycleindex.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1026:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid electron-quick-start@1.0.0
15 verbose cwd E:ПрограммированиеScriptJsWorkspaseMyProgrammelectron-quick-start
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
18 verbose node v13.11.0
19 verbose npm  v6.13.7
20 error code ELIFECYCLE
21 error errno 1
22 error electron-quick-start@1.0.0 start: `electron .`
22 error Exit status 1
23 error Failed at the electron-quick-start@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

How can I fix npm errors and warnings? It worked before… But now it doesn’t work… Also does npm audit fix work?

npm -v
6.14.6 node -v v12.18.4

npm notice created a lockfile as package-lock.json. You should commit
this file. npm WARN meeting@1.0.0 No description npm WARN
meeting@1.0.0 No repository field.

  • lite-server@2.5.4 added 217 packages from 213 contributors and audited 217 packages in 8.82s

4 packages are looking for funding run npm fund for details

found 1 low severity vulnerability run npm audit fix to fix them,
or npm audit for details

Users-MacBook-Pro:meeting user$ npm fund
meeting@1.0.0 ├─┬ https://github.com/sponsors/jonschlinkert │ └──
picomatch@2.2.2 ├─┬ https://github.com/sponsors/RubenVerborgh │ └──
follow-redirects@1.13.0 ├─┬ https://github.com/sponsors/sindresorhus │
└── p-limit@2.3.0 └─┬ https://github.com/chalk/ansi-styles?sponsor=1
└── ansi-styles@4.2.1

Users-MacBook-Pro:meeting user$ npm audit fix npm WARN meeting@1.0.0
No description npm WARN meeting@1.0.0 No repository field.

up to date in 0.69s

4 packages are looking for funding run npm fund for details

fixed 0 of 1 vulnerability in 217 scanned packages 1 vulnerability
required manual review and could not be updated
Users-MacBook-Pro:meeting user$

  • npm
  • npm-install
  • npm-scripts
  • npm-start
  • lite-server

bad_coder's user avatar

bad_coder

11k20 gold badges42 silver badges70 bronze badges

asked Oct 4, 2020 at 18:22

Heejung Lee's user avatar

2

  • It’s better to wrap console output in a quote or code block. If you put it in like normal text then it’s hard to find your question in it. There’s not much to fix. Some npm packages have vulnerabilities found over time. Mostly it goes away when you update your dependencies. As for your package (meeting@1.0.0) WARN. Happens if you initiate your package with default values (npm init -y). It doesn’t impact how your package works and you don’t need to do anything about it if it’s local only project. Check documentation for more info.

    Oct 4, 2020 at 20:39

Load 7 more related questions

Show fewer related questions

I am working on an angular app with a .net core web api.

When I cloned this repository, I tried to run npm install on the angular application, but I got a strange error:

npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

audited 34090 packages in 14.711s
found 15 vulnerabilities (9 low, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details 

Also, if I try to do npm audit fix, I get even more errors:


npm audit fix
npm ERR! code ELOCKVERIFY
npm ERR! Errors were found in your package-lock.json, run  npm install  to fix them.
npm ERR!     Invalid: lock file's @progress/kendo-theme-default@file:https:/registry.npmjs.org/@progress/kendo-theme-default/-/kendo-theme-default-2.48.1.tgz does not satisfy @progress/kendo-theme-default@file:lib/kendo-theme-default
npm ERR!     Invalid: lock file's bootstrap@file:https:/registry.npmjs.org/bootstrap/-/bootstrap-4.0.0.tgz does not satisfy bootstrap@file:lib/bootstrap

How can I resolve this?

TLDR;

  • Run the npm audit command
  • Scroll until you find a line of text separating two issues
  • Manually run the command given in the text to upgrade one package at a time, e.g. npm i --save-dev jest@24.8.0
  • After upgrading a package make sure to check for breaking changes before upgrading the next package
  • Avoid running npm audit fix --force

Vulnerabilities

Every now and then after installing your projects dependencies, npm i, you will be met with an error from NPM that looks something like

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ braces                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ jest [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ jest > jest-cli > micromatch > braces                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/786                       │
└───────────────┴──────────────────────────────────────────────────────────────┘


found 62 low severity vulnerabilities in 20610 scanned packages
  62 vulnerabilities require semver-major dependency updates.

This is actually an extremely small example of a typical vulnerability warning. As you can see from the text underneath the vulnerability it says

found 62 low severity vulnerabilities in 20610 scanned packages
  62 vulnerabilities require semver-major dependency updates.

Meaning that this example would have another 61 vulnerabilities ranging from low to high with of course high being the most dangerous vulnerability. For more info on any of these vulnerabilities, there is also a link to the vulnerability on NPM inside the More Info section of the warning.

At first, it may seem confusing on how to properly fix these vulnerabilities. NPM actually provides a service built into NPM that is supposed to automatically fix these issues, npm audit fix, but I’ve found that this will rarely work, and will leave you with nearly just as many vulnerabilities as before. In fact, here’s an example of what happened after I ran npm audit fix.

fixed 0 of 62 vulnerabilities in 20610 scanned packages
  1 package update for 62 vulns involved breaking changes
  (use `npm audit fix --force` to install breaking changes; or refer to `npm audit` for steps to fix these manually)

NPM gives us the option to use the --force flag, npm audit fix --force, but even NPM will warn you about using this flag

user@group:~/npm_project$ npm audit fix --force
npm WARN using --force I sure hope you know what you are doing.

So what are we supposed to do? If our package manager isn’t able to fix these vulnerabilities then surely we’re out of luck and must find a way to survive with these vulnerabilities hoping nobody decides to exploit them against our project.

The Fix

Manually upgrade the packages one at a time with the command suggested by NPM instead of running the npm audit fix --force command. For example npm install --save-dev jest@24.8.0.

First of all, I want to say that this might be incredibly obvious to those that have run into this problem before. When I first saw these, it was a gigantic list of warnings and being the lazy developer that I am, I didn’t even bother to scroll through the issues.

If you just continue to scroll up inside your console to the very first issue you’ll actually run into a fix and yes, as you would expect, it’s as simple as updating the package that’s causing the issue.

user@group:~/npm_project$ npm audit --fix

                       === npm audit security report ===                        

# Run  npm install --save-dev jest@24.8.0  to resolve 62 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ braces                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ jest [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ jest > jest-cli > jest-config > babel-jest >                 │
│               │ babel-plugin-istanbul > test-exclude > micromatch > braces   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/786                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

... 61 more vulerabilities ...

Right before the vulnerability issue you’ll notice the text # Run npm install --save-dev jest@24.8.0 to resolve 62 vulnerabilities which is exactly what we’re looking for. You may also notice that the very next line says SEMVER WARNING: Recommended action is a potentially breaking change. Manually running this command instead of using the npm audit fix --force command lets us know exactly which packages we’re updating. This is valuable for the scenario where updating these packages actually causes a breaking change.

Summary

So in the end, manually upgrading the vulnerable packages and running npm audit fix --force is going to have the same results. The only difference is that manually upgrading our packages will allow us to upgrade a single package, test for a breaking change, then update the next package, instead of just upgrading all of the packages at once, find a breaking change, then having no idea which package decided to screw things up.

NPM дает нам возможность использовать флаг –force, то есть npm audit fix –force но NPM предупредит вас об использовании этого флага:

npm audit fix --force
npm WARN using --force I sure hope you know what you are doing.

Так что же нам делать?

Если наш менеджер пакетов не может исправить эти уязвимости, то, конечно, нам не повезло, и мы должны найти способ выжить с этими уязвимостями, надеясь, что никто не решит использовать их против нашего проекта.

Исправление

Обновляйте пакеты по одному с помощью команды, предложенной NPM, вместо запуска команды npm audit fix –force.

Например, npm install –save-dev jest@24.8.0.

Прежде всего, я хочу сказать, что это может быть невероятно очевидно для тех, кто сталкивался с этой проблемой раньше.

Когда я впервые увидел всеэ то, это был гигантский список предупреждений, и, будучи ленивым, я даже не удосужился прокрутить список проблем.

Если вы просто продолжите прокручивать внутри своей консоли до самой первой проблемы, вы фактически столкнетесь с исправлением, и да, как и следовало ожидать, это так же просто, как обновить пакет, вызывающий проблему.

 npm audit --fix

                       === npm audit security report ===                        

# Run  npm install --save-dev jest@24.8.0  to resolve 62 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ braces                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ jest [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ jest > jest-cli > jest-config > babel-jest >                 │
│               │ babel-plugin-istanbul > test-exclude > micromatch > braces   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/786                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

... 61 more vulerabilities ...

Прямо перед описанием уязвимости вы увидите текст # Run npm install –save-dev jest@24.8.0 to resolve 62 vulnerabilities чтобы устранить 62 уязвимости, и это именно то, что нам нужно.

Вы также можете заметить, что в следующей строке написано SEMVER WARNING: SEMVER WARNING: Recommended action is a potentially breaking change.

Выполнение этой команды вручную вместо использования иnpm audit fix –force позволяет нам точно знать, какие пакеты мы обновляем.

Это очень полезно для скриптов, в котором обновление этих пакетов действительно приводит к серьезным изменениям.

Заключение

В итоге, ручное обновление уязвимых пакетов и запуск исправления аудита npm –force даст те же результаты.

Единственное отличие состоит в том, что ручное обновление наших пакетов позволит нам обновить один пакет, протестировать на наличие критических изменений, а затем обновить следующий пакет, вместо того, чтобы просто обновить все пакеты сразу, найти критическое изменение и не иметь представления какой пакет решил все испортить.

Понравилась статья? Поделить с друзьями:
  • Npm init y ошибка
  • Npm err code enoent ошибка
  • Nox ошибка 1017
  • Np 41772 1 ошибка ps4 как исправить
  • Nox ошибка 1014