Npm install g npm ошибка

learn you some npm for great good. Contribute to Pebbles0/docs development by creating an account on GitHub.

Random Errors—One Place to Start

  • Some strange issues can be resolved by simply running npm cache clean and trying again.
  • If you are having trouble with npm install, use the -verbose option to see more details.

No compatible version found

You have an outdated npm. Please update to the latest stable npm.

Permissions Errors

Please see the discussions in Chapter 2 and Chapter 3 about ways to avoid permissions errors.

Error: ENOENT, stat 'C:Users<user>AppDataRoamingnpm' on Windows 7

This is a consequence of joyent/node#8141, and is an issue with the Node installer for Windows. The workaround is to ensure that C:Users<user>AppDataRoamingnpm exists and is writable with your normal user account.

No space

npm ERR! Error: ENOSPC, write

You are trying to install on a drive that either has no space, or has no permission to write.

  • Free some disk space or
  • Set the tmp folder somewhere with more space: npm config set tmp /path/to/big/drive/tmp or
  • Build Node yourself and install it somewhere writable with lots of space.

No git

npm ERR! not found: git
ENOGIT

You need to install git. Or, you may need to add your git information to your npm profile. You can do this from the command line or from the website.

running a Vagrant box on Windows fails due to path length issues

@drmyersii went through what sounds like a lot of painful trial and error to come up with a working solution involving Windows long paths and some custom Vagrant configuration:

This is the commit that I implemented it in, but I’ll go ahead and post the main snippet of code here:

config.vm.provider "virtualbox" do |v|
    v.customize ["sharedfolder", "add", :id, "--name", "www", "--hostpath", (("//?/" + File.dirname(__FILE__) + "/www").gsub("/","\"))]
end

config.vm.provision :shell, inline: "mkdir /home/vagrant/www"
config.vm.provision :shell, inline: "mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` > www /home/vagrant/www", run: "always"

In the code above, I am appending \? to the current directory absolute path. This will actually force the Windows API to allow an increase in the MAX_PATH variable (normally capped at 260). Read more about max path. This is happening during the sharedfolder creation which is intentionally handled by VBoxManage and not Vagrant’s «synced_folder» method. The last bit is pretty self-explanatory; we create the new shared folder and then make sure it’s mounted each time the machine is accessed or touched since Vagrant likes to reload its mounts/shared folders on each load.

npm only uses git: and ssh+git: URLs for GitHub repos, breaking proxies

@LaurentGoderre fixed this with some Git trickery:

I fixed this issue for several of my colleagues by running the following two commands:

git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://

One thing we noticed is that the .gitconfig used is not always the one expected so if you are on a machine that modified the home path to a shared drive, you need to ensure that your .gitconfig is the same on both your shared drive and in c:users[your user]

SSL Error

npm ERR! Error: 7684:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:opensslssls23_clnt.c:787:

You are trying to talk SSL to an unencrypted endpoint. More often than not, this is due to a proxy configuration error (see also this helpful, if dated, guide). In this case, you do not want to disable strict-ssl – you may need to set up a CA / CA file for use with your proxy, but it’s much better to take the time to figure that out than disabling SSL protection.

npm ERR! Error: SSL Error: CERT_UNTRUSTED
npm ERR! Error: SSL Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE

This problem will happen if you’re running Node 0.6. Please upgrade to node 0.8 or above. See this post for details.

You could also try these workarounds: npm config set ca "" or npm config set strict-ssl false

npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN

npm no longer supports its self-signed certificates

Either:

  • upgrade your version of npm npm install npm -g --ca=""
  • tell your current version of npm to use known registrars npm config set ca=""

If this does not fix the problem, then you may have an SSL-intercepting proxy.
(For example, npm/npm#7439 (comment))

SSL-intercepting proxy

Unsolved. See npm/npm#9282

Not found / Server error

npm http 404 https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz
npm ERR! Error: 404 Not Found
npm http 500 https://registry.npmjs.org/phonegap
  • It’s most likely a temporary npm registry glitch. Check npm server status and try again later.
  • If the error persists, perhaps the published package is corrupt. Contact the package owner and have them publish a new version of the package.

Invalid JSON

npm ERR! SyntaxError: Unexpected token <
npm ERR! registry error parsing json
  • Possible temporary npm registry glitch, or corrupted local server cache.
    Run npm cache clean and/or try again later.
  • This can be caused by corporate proxies that give HTML
    responses to package.json requests. Check npm’s proxy configuration.
  • Check that it’s not a problem with a package you’re trying to install
    (e.g. invalid package.json).

Many ENOENT / ENOTEMPTY errors in output

npm is written to use resources efficiently on install, and part of this is that it tries to do as many things concurrently as is practical. Sometimes this results in race conditions and other synchronization issues. As of npm 2.0.0, a very large number of these issues were addressed. If you see ENOENT lstat, ENOENT chmod, ENOTEMPTY unlink, or something similar in your log output, try updating npm to the latest version. If the problem persists, look at npm/npm#6043 and see if somebody has already discussed your issue.

cb() never called! when using shrinkwrapped dependencies

Take a look at issue #5920. We’re working on fixing this one, but it’s a fairly subtle race condition and it’s taking us a little time. You might try moving your npm-shrinkwrap.json file out of the way until we have this fixed. This has been fixed in versions of npm newer than npm@2.1.5, so update to npm@latest.

npm login errors

Sometimes npm login fails for no obvious reason. The first thing to do is to log in at https://www.npmjs.com/login and check that your e-mail address on npmjs.com matches the
email address you are giving to npm login.

If that’s not the problem, or if you are seeing the message "may not mix password_sha and pbkdf2", then

  1. Log in at https://npmjs.com/
  2. Change password at https://npmjs.com/password – you can even «change» it to the same password
  3. Clear login-related fields from ~/.npmrc – e.g., by running sed -ie '/registry.npmjs.org/d' ~/.npmrc
  4. npm login

and it generally seems to work.

See npm/npm#6641 (comment) for the history of this issue.

npm hangs on Windows at addRemoteTarball

Check if you have two temp directories set in your .npmrc:

Look for lines defining the tmp config variable. If you find more than one, remove all but one of them.

See npm/npm#7590 for more about this unusual problem.

Why isn’t npm running the latest version on my Windows machine?

See the section about Windows here.


Photo from Unsplash

When running npm commands from the terminal, you may get an error with code ENOENT.

Here’s an example of the error message log when running the npm start command:

$ npm start

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /nsebhastian/Desktop/DEV/n-app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open 
'/nsebhastian/Desktop/DEV/n-app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

As you can see, there’s an error with code ENOENT that prevents npm start command from running successfully.

The code ENOENT means that npm fails to open a file or directory that’s required for executing the command.

The npm start command is used to run the start script in the package.json file.

When the package.json file isn’t found, then npm throws the ENOENT error.

To fix the error, you need to make sure that the file or directory needed for running the command is available.

In the case above, adding a package.json file to the project will solve the error.

If that doesn’t work, then you probably don’t have a start script in your package.json file.

Learn more here: How to fix npm start command not working

Also, make sure that you are running the command from the project directory, right where the package.json file is located.

npm commands don’t work when you run them from a parent or child directory.

npm install fails with code ENOENT

The ENOENT error may also appear when you run the npm install command.

Here’s an example of the error:

$ npm install

npm ERR! path /Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 
'/Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates' -> '/Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/.delegates.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

The error above happens because you have a dependency that doesn’t install correctly.

Here are the steps to resolve this issue:

  • Make sure you are using the latest npm version
  • Clean your npm cache
  • Delete node_modules folder and package-lock.json
  • Run npm install again

Run the following commands one by one from the terminal:

# 👇 update npm to the latest version
npm install -g npm@latest

# 👇 clean npm cache
npm cache clean --force

# 👇 delete node modules and package-lock.json 
npm rm -rf node_modules && rm package-lock.json

# 👇 retry installing dependencies
npm install

The npm install command should now run successfully.

And that’s how you solve the npm error code ENOENT: no such file or directory error.

1. Purpose

In this post, I would demo how to solve the following error when doing npm install:

[email protected]:/opt/White-Jotter/wj-vue# npm install
npm WARN deprecated [email protected]: [email protected]<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm WARN deprecated [email protected]: Support has ended for 9.x series. Upgrade to @latest
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated [email protected]: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated [email protected]: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated [email protected]: out of support
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm ERR! Linux 4.15.0-128-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /opt/White-Jotter/wj-vue/npm-debug.log
[email protected]:/opt/White-Jotter/wj-vue#

The core error message is:

npm ERR! Linux 4.15.0-128-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /opt/White-Jotter/wj-vue/npm-debug.log

2. The environment

  • Ubuntu 18.04.5 LTS
  • npm version
[email protected]:~# npm version
{ npm: '3.5.2',
  ares: '1.14.0',
  cldr: '32.0.1',
  http_parser: '2.7.1',
  icu: '60.2',
  modules: '57',
  nghttp2: '1.30.0',
  node: '8.10.0',
  openssl: '1.0.2n',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.18.0',
  v8: '6.2.414.50',
  zlib: '1.2.11' }
[email protected]:~#

3. The solution

It seems that my npm version is too old, it needs to be upgraded, so I tried this:

[email protected]:~# npm install -g npm
▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine [email protected]: wanted: {"node":"^12.13.0 || ^14.15.0 || >=16"} (current: {"node":"8.10.0","npm":"3.5.2"})
/usr/local/lib
└── (empty)

npm ERR! Linux 4.15.0-128-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "npm"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a' -> '/usr/local/lib/node_modules/npm/node_modules/@gar/promisify'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a' -> '/usr/local/lib/node_modules/npm/node_modules/@gar/promisify'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
npm ERR! code 1

It’s not working, It seems that the npm and nodejs is integrated by the system, so I decided to remove them from the system:

[email protected]:~# apt purge npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gyp javascript-common libc-ares2 libhttp-parser2.7.1 libjs-async libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libssl1.0-dev libuv1
  libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-balanced-match node-block-stream node-brace-expansion
  node-builtin-modules node-combined-stream node-concat-map node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fs.realpath
  node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-hosted-git-info node-inflight node-inherits node-ini
  node-is-builtin-module node-isexe node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream
  node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-path-is-absolute node-pseudomap node-qs node-read
  node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-slide node-spdx-correct node-spdx-expression-parse
  node-spdx-license-ids node-tar node-tunnel-agent node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist nodejs nodejs-dev
  nodejs-doc
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  npm*
0 upgraded, 0 newly installed, 1 to remove and 144 not upgraded.
After this operation, 10.7 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 117180 files and directories currently installed.)
Removing npm (3.5.2-0ubuntu4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
[email protected]:~# apt purge node
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package node
[email protected]:~#

And then install it again:

Then I upgraded npm using the following command:

Node has a module called n, which is specifically used to manage the version of node.js. Use npm (NPM is a package management tool installed with nodejs) to install the n module:

Then upgrade the node.js to the latest version:

Now upgrade the npm again:

[email protected]:~# npm install npm -g

removed 2 packages, changed 15 packages, and audited 219 packages in 7s

10 packages are looking for funding
  run `npm fund` for details

3 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
npm notice
npm notice New patch version of npm available! 8.1.0 -> 8.1.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.3
npm notice Run npm install -g [email protected] to update!
npm notice

Now check the npm version:

[email protected]:~# npm version
{
  npm: '8.1.3',
  node: '16.13.0',
  v8: '9.4.146.19-node.13',
  uv: '1.42.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.17.2',
  modules: '93',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '1.1.1l+quic',
  cldr: '39.0',
  icu: '69.1',
  tz: '2021a',
  unicode: '13.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

Now run npm install again:

[email protected]:~# npm install

up to date, audited 127 packages in 12s

2 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

Now It’s working!

4. Summary

In this post, I demonstrated how to solve the npm upgrade error, you can try as mine. That’s it, thanks for your reading.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Npm install error node gyp
  • Npm init y ошибка
  • Npm error missing script start
  • Npm error http error
  • Npm error e401 unable to authenticate need basic realm sonatype nexus repository manager

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии