Npm install windows 10 не работает

This works great in my Mac. But the same process on Windows and the npm install crashes. This is what I get. I've tried everything I've seen on Stack Overflow so far and every link Google search pr...

This works great in my Mac. But the same process on Windows and the npm install crashes. This is what I get.

I’ve tried everything I’ve seen on Stack Overflow so far and every link Google search produced. I tried the following as suggested here:

rm -rf node_modules
npm install

It didn’t work.

I:

  • ran it as admin,

  • tried npm install -g

  • restarted the XAMPP server

  • turned off Windows Defender

  • checked the PATH for C:Program Filesnodejs

Output

warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_moduleschokidarnode_modulesfsevents):
warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
warn fuse@1.4.4 No description
verbose If you need help, you may report this error at:
verbose     <https://github.com/npm/npm/issues>
warn fuse@1.4.4 No repository field.
verbose If you need help, you may report this error at:
verbose     <https://github.com/npm/npm/issues>
warn fuse@1.4.4 No license field.
verbose If you need help, you may report this error at:
verbose     <https://github.com/npm/npm/issues>
verbose stack Error: EPERM: operation not permitted, rename 'C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290' -> 'C:xampphtdocsScalaCMnode_modulesaccessibility-developer-tools'
verbose stack     at destStatted (C:UsersLuisAppDataRoamingnpmnode_modulesnpmlibinstallactionfinalize.js:25:7)
verbose stack     at C:UsersLuisAppDataRoamingnpmnode_modulesnpmnode_modulesgraceful-fspolyfills.js:276:29
verbose stack     at FSReqWrap.oncomplete (fs.js:123:15)
verbose stack
verbose stack Error: EPERM: operation not permitted, rename 'C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290' -> 'C:xampphtdocsScalaCMnode_modulesaccessibility-developer-tools'
verbose stack     at Error (native)
verbose cwd C:xampphtdocsScalaCM
error Windows_NT 10.0.14393
error argv "C:\Program Files\nodejs\node.exe" "C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install"
error node v6.9.1
error npm  v4.0.2
error path C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290
error code EPERM
error errno -4048
error syscall rename
error Error: EPERM: operation not permitted, rename 'C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290' -> 'C:xampphtdocsScalaCMnode_modulesaccessibility-developer-tools'
error     at destStatted (C:UsersLuisAppDataRoamingnpmnode_modulesnpmlibinstallactionfinalize.js:25:7)
error     at C:UsersLuisAppDataRoamingnpmnode_modulesnpmnode_modulesgraceful-fspolyfills.js:276:29
error     at FSReqWrap.oncomplete (fs.js:123:15)
error
error Error: EPERM: operation not permitted, rename 'C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290' -> 'C:xampphtdocsScalaCMnode_modulesaccessibility-developer-tools'
error     at Error (native)
error  { Error: EPERM: operation not permitted, rename 'C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290' -> 'C:xampphtdocsScalaCMnode_modulesaccessibility-developer-tools'
error     at destStatted (C:UsersLuisAppDataRoamingnpmnode_modulesnpmlibinstallactionfinalize.js:25:7)
error     at C:UsersLuisAppDataRoamingnpmnode_modulesnpmnode_modulesgraceful-fspolyfills.js:276:29
error     at FSReqWrap.oncomplete (fs.js:123:15)
error
error Error: EPERM: operation not permitted, rename 'C:xampphtdocsScalaCMnode_modules.stagingaccessibility-developer-tools-2e33f290' -> 'C:xampphtdocsScalaCMnode_modulesaccessibility-developer-tools'
error     at Error (native) parent: 'fuse' }
error Please try running this command again as root/Administrator.
verbose exit [ -4048, true ]

node -v gives me version 6.9.1.

npm -v gives me version 4.0.2.

Which proves they are all installed fine. Am I right?

I have installed nodejs latest on Windows 10 (64-bit) and the PATH is already setup. Now when i am trying to install any npm modules globally using npm install -g <packagename>then I am getting the following error:

npm install -g <packagename>
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "<packagename>"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10

npm ERR! 1961 == 0
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

The npm-debug.log shows:

0 info it worked if it ends with ok
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   'install',
1 verbose cli   '-g',
1 verbose cli   'yo' ]
2 info using npm@3.10.10
3 info using node@v6.9.5
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData yo
8 silly fetchNamedPackageData yo
9 silly mapToRegistry name yo
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry https://registry.npmjs.org/
12 silly mapToRegistry data Result {
12 silly mapToRegistry   raw: 'yo',
12 silly mapToRegistry   scope: null,
12 silly mapToRegistry   escapedName: 'yo',
12 silly mapToRegistry   name: 'yo',
12 silly mapToRegistry   rawSpec: '',
12 silly mapToRegistry   spec: 'latest',
12 silly mapToRegistry   type: 'tag' }
13 silly mapToRegistry uri https://registry.npmjs.org/yo
14 verbose request uri https://registry.npmjs.org/yo
15 verbose request no auth needed
16 info attempt registry request try #1 at 3:40:19 PM
17 verbose request id 09fae89b96705683
18 http request GET https://registry.npmjs.org/yo
19 verbose stack AssertionError: 1961 == 0
19 verbose stack     at ClientRequest.onConnect (C:Program Filesnodejsnode_modulesnpmnode_modulesrequestnode_modulestunnel-agentindex.js:159:14)
19 verbose stack     at ClientRequest.g (events.js:291:16)
19 verbose stack     at emitThree (events.js:116:13)
19 verbose stack     at ClientRequest.emit (events.js:194:7)
19 verbose stack     at Socket.socketOnData (_http_client.js:395:11)
19 verbose stack     at emitOne (events.js:96:13)
19 verbose stack     at Socket.emit (events.js:188:7)
19 verbose stack     at readableAddChunk (_stream_readable.js:176:18)
19 verbose stack     at Socket.Readable.push (_stream_readable.js:134:10)
19 verbose stack     at TCP.onread (net.js:548:20)
20 verbose cwd C:wamp64wwwkvm-emart
21 error Windows_NT 10.0.14393
22 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "yo"
23 error node v6.9.5
24 error npm  v3.10.10
25 error 1961 == 0
26 error If you need help, you may report this error at:
26 error     <https://github.com/npm/npm/issues>
27 verbose exit [ 1, true ]

I do not understand the error in windows 10 while installing npm packages. Please let me know if this can be fixed.


Photo from Unsplash

The npm install command is used for installing JavaScript packages on your local computer.

When developing web projects, you may see issues that cause the npm install command to fail.

You need to see the error message generated in the terminal for clues to resolve the error.

Some of the most common issues for npm install not working are as follows:

  • npm command not found
  • No package.json file describing the dependencies
  • Integrity check failed error
  • For Windows: Python not found

Let’s see how you can resolve these errors next.

The npm command not found error

To run the npm install command, you need to have npm installed on your computer

$ npm install
sh: command not found: npm

The error above happens when npm can’t be found under the PATH environment variable.

First, you need to make sure that npm is installed on your computer.

npm is bundled with Node.js server, which you can download from the nodejs.org website.

Once you downloaded and installed Node.js, open the terminal and run the npm -v command.

You should see the version of npm installed on your computer as follows:

Once you see the npm version, you should be able to run the npm install command again.

For more details, visit the fixing npm command not found error article I’ve written previously.

ENOENT: No package.json file

The npm install command looks for a package.json file in order to find the packages it needs to install.

You need to make sure you have a package.json file right in the current directory where you run the command.

You can run the ls -1 command as follows:

$ ls -1
index.js
package-lock.json
package.json

Once you see there’s a package.json file in the output as shown above, then you can run the npm install command.

For this reason, you should always run the npm install command from the root directory of your project.

By the way, npm install will install packages already listed under the dependencies object of your package.json file.

Suppose you have a package.json file as shown below:

{
  "name": "n-app",
  "version": "1.0.0",
  "description": "A Node application",
  "dependencies": {
    "jest": "^28.1.1",
    "typescript": "^4.5.5",
    "webpack": "^2.7.0"
  }
}

Then npm install will install jest, typescript, and webpack to the generated node_modules/ folder.

If you need to install a new package, then you need to specify the name like these examples:

# 👇 install react package
npm install react

# 👇 install react, react-dom, and axios packages
npm install react react-dom axios

You can install one or many packages with the npm install command.

Integrity check failed error

When you have a package-lock.json file in your project, then npm will check the integrity of the package you downloaded with the one specified in the lock file.

When the checksum of the package is different, then npm will stop the installation and throw the integrity check failed error.

The following is an example of the error:

npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting @my-package@^1.2.0:
npm ERR! Verification failed while extracting @my-package@^1.2.0:
npm ERR! Integrity check failed:

npm ERR! Wanted: sha512-lQ...HA== 
npm ERR! Found:  sha512-Mj...vg==

When this happens, you can fix the issue by verifying the cache:

When the command is finished, run npm install again.

If you still see the error, then delete your lock file and clean the npm cache.

Run the following commands from your project’s root directory:

# 👇 remove the lock file
rm package-lock.json

# 👇 remove the node_modules folder
rm -rf node_modules

# 👇 Clear the npm cache
npm cache clean --force

# 👇 run npm install again
npm install

That should fix the issue with the integrity check.

For Windows only: Python not found

When running npm install on Windows, you may see an error that says Can’t find Python executable as shown below:

> node-gyp rebuild

/n-app>node "..node_modulesnode-gypbinnode-gyp.js" rebuild
npm http 304 https://registry.npmjs.org/bcrypt
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python",
you can set the PYTHON env variable.

The node-gyp module is a Node.js tool for compiling native modules written in C and C++. It requires Python to run properly.

Instead of installing Python by yourself, you can install the Windows Build Tools which has Python included.

This is because Windows also requires Visual Studio build tools to make node-gyp run successfully.

If you install only Python, then you may find that you need the build tools later.

Please note that the latest version of Node.js for Windows installer already includes the build tools by default.

But if you can’t update your Node.js version yet, then installing the build tools manually should help you fix this error.

Conclusion

The npm install command may fail to work because of many reasons.

When the command doesn’t work, you need to check the output first and see what specific error you have.

Try a Google search to fix the issue. When you don’t see a solution, try posting a new question at Stack Overflow mentioning the things you have tried to fix the issue.

Good luck resolving the issue! 👍

прописал путь до exe , скачал и msbuild2015

и все равно при установки npm пакета ошибки :

D:WORK-projects48724-pink {git}{hg}
{lamb} npm i —save-dev load-grunt-tasks

> bufferutil@1.2.1 install D:WORK-projects48724-pinknode_modulesbufferutil
> node-gyp rebuild

D:WORK-projects48724-pinknode_modulesbufferutil {git}{hg}
{lamb} if not defined npm_config_node_gyp (node «C:UsersplueAppDataRoamingnpmnode_modulesnpmbinnode-gyp-bin\….node_modulesnode-gypbinnode-gyp.js» rebuild ) else (node «» rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр «/m».
C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140Platformsx64PlatformToolsetsv140Toolset.targets(36,
5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or c
hange the SDK version in the project property pages or by right-clicking the solution and selecting «Retarget
solution». [D:WORK-projects48724-pinknode_modulesbufferutilbuildbufferutil.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:Program Files (x86)MSBuild14.0binmsbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:UsersplueAppDataRoamingnpmnode_modulesnpmnode_modulesnode-gyplibbuild.js:276:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command «C:\Program Files\nodejs\node.exe» «C:\Users\plue\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js» «rebuild»
gyp ERR! cwd D:WORK-projects48724-pinknode_modulesbufferutil
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil@1.2.1 Exit status 1

> utf-8-validate@1.2.1 install D:WORK-projects48724-pinknode_modulesutf-8-validate
> node-gyp rebuild

D:WORK-projects48724-pinknode_modulesutf-8-validate {git}{hg}
{lamb} if not defined npm_config_node_gyp (node «C:UsersplueAppDataRoamingnpmnode_modulesnpmbinnode-gyp-bin\….node_modulesnode-gypbinnode-gyp.js» rebuild ) else (node «» rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр «/m».
C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140Platformsx64PlatformToolsetsv140Toolset.targets(36,
5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or c
hange the SDK version in the project property pages or by right-clicking the solution and selecting «Retarget
solution». [D:WORK-projects48724-pinknode_modulesutf-8-validatebuildvalidation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:Program Files (x86)MSBuild14.0binmsbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:UsersplueAppDataRoamingnpmnode_modulesnpmnode_modulesnode-gyplibbuild.js:276:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command «C:\Program Files\nodejs\node.exe» «C:\Users\plue\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js» «rebuild»
gyp ERR! cwd D:WORK-projects48724-pinknode_modulesutf-8-validate
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: `node-gyp rebuild`
npm WARN install:utf-8-validate@1.2.1 Exit status 1
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12

C:cmder/vendor/clink-completions/npm_prompt.lua:11: attempt to concatenate local ‘package_name’ (a nil value)
D:WORK-projects48724-pink {git}{hg}

I have a trouble with npm and I haven’t found solution in web.

Today I wanted to start my adventure with nodejs, npm, bower etc.

I use Windows 8.1.

I installed the newest nodejs (v0.12.0). I tried these steps with both x64 and x86 builds.
I opened nodejs command line with administrative privileges.
I updated npm to 2.5.0 version.
When I run npm install bower -g I see a char that seems to show progress (it’is rolling) but nothing happens. Even if I leave it «working» for a 30 minutes, nothing happens. It never ends.
When I type np ls -g it shows only npm@2.5.0 and it’s dependencies.

I don’t know what other info I could provide. There are no errors nor logs.
Please, help.

Updated

Logs:

npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli   'C:\Users\Lucek\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
npm verb cli   '--verbose',
npm verb cli   'install',
npm verb cli   'bower',
npm verb cli   '-g' ]
npm info using npm@2.5.0
npm info using node@v0.12.0
npm verb cache add spec bower
npm verb addNamed bower@*
npm verb addNameRange registry:https://registry.npmjs.org/bower not in flight; fetching
npm verb request uri https://registry.npmjs.org/bower
npm verb request no auth needed
npm info attempt registry request try #1 at 08:43:01
npm verb request id 8d309c5e387572c0
npm verb etag "CQDT3LW680UJR78VNWVFLN8Q7"
npm http request GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
npm verb get saving bower to C:UsersLucekAppDataRoamingnpm-cacheregistry.npmjs.orgbower.cache.json
npm verb addNamed bower@1.3.12
npm verb addRemoteTarball https://registry.npmjs.org/bower/-/bower-1.3.12.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/bower/-/bower-1.3.12.tgz',
npm verb addRemoteTarball   '37de0edb3904baf90aee13384a1a379a05ee214c' ]

I have a trouble with npm and I haven’t found solution in web.

Today I wanted to start my adventure with nodejs, npm, bower etc.

I use Windows 8.1.

I installed the newest nodejs (v0.12.0). I tried these steps with both x64 and x86 builds.
I opened nodejs command line with administrative privileges.
I updated npm to 2.5.0 version.
When I run npm install bower -g I see a char that seems to show progress (it’is rolling) but nothing happens. Even if I leave it «working» for a 30 minutes, nothing happens. It never ends.
When I type np ls -g it shows only npm@2.5.0 and it’s dependencies.

I don’t know what other info I could provide. There are no errors nor logs.
Please, help.

Updated

Logs:

npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli   'C:\Users\Lucek\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
npm verb cli   '--verbose',
npm verb cli   'install',
npm verb cli   'bower',
npm verb cli   '-g' ]
npm info using npm@2.5.0
npm info using node@v0.12.0
npm verb cache add spec bower
npm verb addNamed bower@*
npm verb addNameRange registry:https://registry.npmjs.org/bower not in flight; fetching
npm verb request uri https://registry.npmjs.org/bower
npm verb request no auth needed
npm info attempt registry request try #1 at 08:43:01
npm verb request id 8d309c5e387572c0
npm verb etag "CQDT3LW680UJR78VNWVFLN8Q7"
npm http request GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
npm verb get saving bower to C:UsersLucekAppDataRoamingnpm-cacheregistry.npmjs.orgbower.cache.json
npm verb addNamed bower@1.3.12
npm verb addRemoteTarball https://registry.npmjs.org/bower/-/bower-1.3.12.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/bower/-/bower-1.3.12.tgz',
npm verb addRemoteTarball   '37de0edb3904baf90aee13384a1a379a05ee214c' ]

This post is for all javascript newbies. If you are getting an «npm command not found» error and want to resolve it. You have landed on the right page. When I installed this node package manager first time, I also got this error. You will get hundreds of solutions and commands on the internet, but I will give you bullseye commands.

I am sure if you will follow this post step by step. You will be able to resolve the following errors. Doesn’t matter which platform or operating system you are using.

You may also find similar errors related to npm as follows-

  • sudo npm command not found
  • mac npm command not found
  • bash npm command not found
  • npm command not found windows
  • npm command not found ubuntu
  • npm install not working

This issue may occur when you have recently installed or upgraded npm (node package manager) and node js.

Possible Causes —

  1. npm is not correctly installed
  2. Node js is not installed
  3. Path or system variable changed
  4. Permission issues
  5. The old node version installed
  6. No package.json file describing the dependencies
  7. Integrity check failed error

Articles on troubleshooting, you may find useful —

  • Yarn command not found error
  • Sudo command not found error
  • Fix «mkvirtualenv command not found» error
  • Nodemon command not found
  • Nodemon app crashed — Waiting for file changes before starting
  • Keytool command issues
  • Cmake command errors

Table of Contents

  • 1 Solution 1 — How to fix npm command not found in Windows 10
  • 2 Solution 2 — How to fix npm command not found in Ubuntu
  • 3 Solution 3 — How to Fix npm command not found — Mac
  • 4 Solution 4 — Path or system variable changed resulting in npm error
  • 5 Solution 5 — Permission issues on «node_modules»
  • 6 Solution 6 — Old Node version installed
  • 7 Solution 7 — No package.Json file issue
  • 8 Solution 8 — Integrity check failed
  • 9 FAQs:- NPM command not found
  • 10 Conclusion

Solution 1 — How to fix npm command not found in Windows 10

If you don’t know the pre-requisite and correct way of npm installation. Then, you will definitely land into this npm error situation. If you have npm already installed then skip to solutions 3, 4 or 5 based on what OS you have to fix your path or system variable.

Let me show you the correct way of npm installation in windows.

How to install node js on Windows 10

Watch out for this video tutorial to know how to install Node JS and NPM correctly in windows 10. If you want to check out the step-by-step tutorial, keep reading.

Step1 — Download Node Js

Download Node.js software from the nodejs.org website. The latest LTS version is node-v14.15.3. Package npm is in-built. You don’t need to install it separately. If you own an old version of windows, select the 32-bit version of the node.js installer. Otherwise, choose 64-bit in all other cases.

Download-node-js

Step2— Install Node.js and npm

Double click installer node-v14.15.3-x64.msi and follow the installation wizard.

Step2.1Accept the terms in the license agreement and click next.

node-js-EULA

Step2.2 — Select the destination folder for node.js installation. Default location of node.js is «C:Program Filesnodejs«. I will recommend keeping it default.

node-js-installation-folder

Step2.3 — Select node.js features. I will suggest you leave it as default. Make a note, that npm (node package manager) will be there as part of this installation. You don’t need to install it separately.

select-npm-to-fix-npm-command-not-found

Step2.4 — Choose an optional tool (chocolatey) to compile native modules, if required. I will suggest you, keep it unchecked.

node-js-dependent-native-modules

Step2.5 — Click install, Sit back and relax. it will take a few minutes.

Fix-npm-command-not-found-windows10validating-node-js-and-npm-install

Step 3 — Check npm and node Js version.

Check node js version

C:> node -v 

Check npm (node package manager) version

C:> npm -v

check-node-js-version

Now you will not get any «npm command not found error» in Windows.

Detailed step-by-step guide on, how to install Node JS and npm using PowerShell (Chocolatey) tool.

Solution 2 — How to fix npm command not found in Ubuntu

So we have already seen, how to resolve the npm command not found error in Windows 10 but what about non-windows users. Let me tell you the steps to get rid of these errors if you are a non-Windows user.

  1. sudo npm command not found
  2. bash npm command not found
  3. npm command not found ubuntu

I have taken an example of Ubuntu 20.04 OS and first I will show you the new installation process.

Watch out for this video tutorial for Node js and npm installation in Ubuntu 20.04. In this video, I have shown, more than one way to install it.

  • Using Ubuntu repository
  • Using Node Source repository

If you like reading, instead of watching videos. Keep reading further.

How to install node JS and npm in Ubuntu 20.04

Step1 — Update the Ubuntu repository first

$ sudo apt-get update

apt-get-update

Step2 — Install Node JS First (Recommended)

Run apt-get command to install nodejs package. Check out the suggested package in output, it says npm.

$ sudo apt-get install nodejs

Install-nodejs-using-apt

Step3 — Install npm (node package manager) in Ubuntu 20.04

Sometimes you scratch your head, Why npm command not found error, even after installing the node? Because in Windows, npm is installed with node Js. But in the case of Ubuntu, you need to install it separately.

Now let’s install node package manager (npm) which is required by Node Js. If you will not install this, you will end up with «npm» error.

$ sudo apt-get install npm

Fix-npm-command-not-found-ubuntu

Step4 — Check npm and node js version

Check npm version

$ sudo npm -v 

check-npm-version

Check node version

$ node -v

check-node-js-version

Till this point, you must be good. And further all issues related to «Bash or sudo: npm command not found» will go for sure.

If you are interested in the latest version of npm and node js installation. Checkout out this tutorial on node js and npm using the NodeSource repository

Solution 3 — How to Fix npm command not found — Mac

In case you are facing the issue «npm command not found» in the mac operating system. I will recommend you remove the existing installation and follow these steps to be successful.

Step1 — Remove the node_modules folder

 > rm -rf /usr/local/lib/node_modules

Step2 — Uninstall Node JS using the brew command

> brew uninstall node

Step3 — Install node with —without-npm option.

> brew install node --without-npm

###Then####

> echo prefix=~/.npm-packages >> ~/.npmrc

Step4 — Install the npm package using the install script

> curl -L https://www.npmjs.com/install.sh | sh

Step5 — Set environment variable in Bash

> export PATH="$HOME/.npm-packages/bin:$PATH"
> export PATH="$HOME/.node/bin:$PATH"

This will resolve all your npm-related errors in mac OS. Watch out for the official nodesource installation guide for further reference.

Solution 4 — Path or system variable changed resulting in npm error

Although, Path and variables are set by default when you install node js and npm in Windows and Ubuntu. But in rare cases, it doesn’t happen. Or maybe you messed up with it. Even in that case, you will get the npm command not found error.

Let’s see how to check and set up variables for npm in the case of Ubuntu 20.04

How to check the npm path variable in Ubuntu 20.04

First, you need to make sure, npm is installed, if not, follow the How to install node JS and npm in Ubuntu 20.04 steps in this post.

Step1 — Check the default path for the npm command

$ which npm

Check-npm-path

Step2 — Check /etc/environment file for npm path

Now we need to check, do we have /usr/bin/npm or your npm command path in /etc/environment file.

$ cat /etc/environment

set-npm-path-variable-fix-npm-command-not-found

As you will see, /usr/bin is already part of my environment variable. So I will not get this error. In case you don’t have your npm path in this file, add it.

Step3 — Edit /etc/environment file and add npm path

$ vi /etc/environment

Add npm path till bin folder at the end of environment file separated by a colon «:». Save and exit from file. Make a note, npm path should be within quotes » «.

For example, /usr/bin in my case.

Reload the environment file for changes.

$ source /etc/environment

How to check the npm path variable in Windows 10

First, you need to make sure, node js and npm are installed in Windows 10. If it’s already there, you need to follow these steps

Step1 — Search for environment variable

Step1.1 — Type «environment variable» in the search box and click open.

open-environment-variable-windows10

Step1.2 — Click on «Environment variables» in the Advanced tab of System Properties.

Fix-variable-npm-command-not-found

Step1.3 — Select «Path» and then click Edit.

Edit-environment-variable-npm-command-not-found

Step1.4 — Check for npm path «C:Program Filesnodejs«. It is the default target directory for Node.JS and npm.

If npm variable path doesn’t exist, Click New > Add npm variable path «C:Program Filesnodejs» > Click OK.

Please make a note, that you need to replace the default «C:Program Filesnodejs» with your custom target Folder. In case you have selected a different folder during installation.

add-variable-to-solve-npm-command-not-found

Click OK twice to close all open dialogue boxes.

Solution 5 — Permission issues on «node_modules«

if you are getting permission-related errors, please run this command to give ownership to your user. It’s applicable to mac and Linux users.

For Mac users —

$ sudo chown -R $(whoami):admin /usr/local/lib/node_modules/

For Linux users —

$ sudo chown -R $(whoami):root /usr/local/lib/node_modules/

Make sure you provide the correct path for node_modules.

Solution 6 — Old Node version installed

If you are running an old version of npm already. You can upgrade it to the latest by using the following command to resolve the npm command not found error.

Run this command, if you are running Ubuntu Linux

$ sudo npm install npm@latest -g

Check Node version

$ npm -v

For Windows users

Run the below-mentioned commands in PowerShell one by one.

c:> Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force 
c:> npm install -g npm-windows-upgrade 
c:> npm-windows-upgrade

Check Node version

c:> node -v

Solution 7 — No package.Json file issue

If you run the npm install command and then make sure you have package.json file existing in the same directory. Else you will encounter npm install errors.

  • Run ls -l command to check whether the package.json file exists or not.
$ ls -1
index.js
package-lock.json
package.json
  • Then run npm install command and recommendation are to run it always from the root folder. The npm install command by default install all the packages under the dependencies object of your package.json file.

For example —

{
"name": "sample-app",
"version": "2.0.1",
"description": "A Node app",
"dependencies": {
"jest": "^28.1.1",
"typescript": "^4.5.5",
}
}

In this example, the npm install the command will install jest and typescript packages to the generated node_modules folder as it’s mentioned in the package.json file.

Solution 8 — Integrity check failed

If you have a package.json file under your project directory, and you are trying to run the npm install command. The npm will compare the integrity of the package you downloaded with the one specified in the package-lock.json file. In cases it differs, it will throw an error integrity failed check error.

npm ERR! Verification failed while extracting @my-package@^1.3.0:
npm ERR! Verification failed while extracting @my-package@^1.3.0:
npm ERR! Integrity check failed:

To solve this error, you need to move or delete your lock file and clean the npm cache. Follow these steps from your project’s root directory.

  • Remove or move your package-lock.json file.
$ sudo rm package-lock.json
or
$ sudo mv package-lock.json /tmp
  • Move or delete the node-modules folder. You can also delete it but I will recommend it to move them to a different or /tmp directory to roll back changes, in case required.
$ sudo mv node_modules /tmp

# in case you want to delete

$ sudo rm -rf node_modules
  • Forcefully clear the npm cache
$ npm cache clean --force

Then run the npm install command again. It should fix your integrity issue.

  1. Why NPM command is not working?

    The reason may be either the npm package is not installed, incorrectly installed or the path variable is not set for npm. Install npm and node js package as recommended or set up the npm path variable to resolve it.

  2. What is the NPM Run command?

    npm run-script or npm run (alias) is the command to execute arbitrary package scripts. npm run-script <command> is the syntax. Without <command>, it will list the available scripts.

  3. What does the command npm install do?

    The npm install command helps to install a package and its dependencies. For further help and syntax run: npm install help

  4. Is not recognized as an internal or external command NPM?

    This means the npm command is not recognized. Make sure you install node js software. NPM will automatically install with node.js in the case of Windows. For non-windows users (Linux or Mac), Install node js first and then the npm package individually.

  5. What is Test Command in NPM init?

    If you are creating a module in node.js using the npm init command. The npm test will help you test the run. It is important while integrating with CI/CD tools. If there are problems with tests. Rollback will be done by your CI/CD and actual deployment will not happen.

  6. How do I know if npm is installed?

    Run the npm -v command on the terminal or command prompt, to check whether npm is installed or not. In case you get «npm command not found error». Either npm is not installed or your path variable is not set up correctly.

Conclusion

Based on the error, follow the required solution from the post. I hope, by this time, you would have fixed your issue of the «npm not found error«. Please comment and let me know, which solution fixed your npm issue.

Please share it on your social media page, so that it can be helpful for others also.

Много гуглили, пробовали переустановить node.js с помощью официального установщика, но мой путь npm по-прежнему не работает.

Это не работает

npm install foo

Я получаю сообщение об ошибке: отсутствует модуль npm-cli.js

Через 2 часа поиска в Google я обнаружил обходной путь
Вместо простого « npm » я набираю

node C:Program Filesnodejsnode_modulesnpmbinnpm-cli.js

Но как мне исправить установку nodejs, чтобы я мог просто набрать npm?

17 ответов

Лучший ответ

Вам необходимо добавить C:Program Filesnodejs в переменную среды PATH. Для этого выполните следующие действия:

  1. Используйте чудо-кнопку глобального поиска для поиска «переменных среды»
  2. Нажмите «Изменить системные переменные среды»
  3. Щелкните «Переменные среды» в диалоговом окне.
  4. В поле «Системные переменные» найдите путь и отредактируйте его, включив C:Program Filesnodejs. Убедитесь, что он отделен от других путей символом ;.

Вам придется перезапустить все открытые в настоящий момент командные строки, прежде чем они вступят в силу.


197

James McCormack
29 Июл 2016 в 14:04

Отредактируйте переменные среды System и введите следующий путь:

C:Program Filesnodejsnode.exe;

C:Users{yourName}AppDataRoamingnpm


6

mate00
25 Июл 2019 в 06:18

Если у вас Windows, попробуйте этого чувака:

1.) Найдите переменные среды в поле поиска меню «Пуск».
2.) Щелкните по нему и перейдите к Environment Variables...
3.) Нажмите ПУТЬ , нажмите Edit
4.) Нажмите Создать и попробуйте скопировать и вставить это: C: Program Files nodejs node_modules npm bin

Если у вас возникла ошибка. Сделайте номер 4.) Нажмите «Создать», затем просмотрите папку bin

  • Вы также можете посетить эту ссылку для получения дополнительной информации.


8

user6690322user6690322
28 Окт 2016 в 12:20

Перейдите в панель управления -> Система -> Расширенные настройки системы, затем переменные среды.

Отсюда найдите переменную пути, перейдите в конец строки и вставьте «C: Program Files nodejs node_modules npm bin» (измените путь к каталогу, в котором вы его установили, например, если вы специально установили его где угодно меняй это)


9

Dennington-bear
9 Янв 2015 в 15:52

Я использовал командлет и перешел по пути, по которому вы хотите переключить свои файлы npm. Введите npm root -g , чтобы узнать, по какому пути установлен ваш npm. Затем используйте префикс набора конфигурации npm , и ваш путь npm будет изменен на любой каталог, в котором вы сейчас находитесь.


16

Constantin
27 Июл 2017 в 01:59

Получить путь от npm:

npm config get prefix

И просто в качестве справки на будущее, это путь, который я добавил в Windows 10:

C:Users{yourName}AppDataRoamingnpm


Обновить:

Если вы хотите добавить его для всех пользователей, просто добавьте следующий путь [от @ glenn-lawrence из комментариев]:

%AppData%npm


144

Yar
17 Мар 2020 в 20:32

Я могу быть полным новичком, но я понятия не имел, что мне нужно сначала установить npm-cli. Я просто предположил, что он у меня уже есть.

npm install --global vue-cli


-2

ninjasense
11 Июл 2019 в 02:58

Когда вы находитесь на Windows, но бежите VS Code в Windows Subsystem for Linux вот так

linux@user: /home$ code .

Вы действительно хотите установить NodeJs на Linux с

linux@user: /home$ sudo apt install nodejs

Установка NodeJs на Windows, изменение PATH и перезапуск не принесут вам никаких результатов.


0


22 Апр 2020 в 19:49

Если вы не можете работать с пакетами npm, вероятно, у вас плохая конфигурация с пакетами установки npm, попробуйте следующее:

Выполните следующую команду в своем терминале, чтобы вернуться к реестру по умолчанию.

npm config set registry https://registry.npmjs.org/

https://docs.npmjs.com/misc/config#registry


0

RobC
13 Окт 2019 в 14:12

Добавить Путь к среде

C: Program Files nodejs node.exe; C: Users [ваше имя пользователя] AppData Roaming npm


0

phantomraa
28 Авг 2019 в 01:33

У меня была эта проблема на 2 компьютерах в моем доме с Windows 10 на каждом. Проблема началась, когда мне пришлось изменить несколько переменных среды для проектов, над которыми я работал над Visual Studio 2017 и т. Д. После нескольких месяцев, когда я вернулся к использованию node js и npm, у меня снова возникла эта проблема, и ни одно из вышеперечисленных решений не помогло. Я видел комментарий Шона к решению Яра и смешал оба решения: 1) в окне переменных среды у меня была одна дополнительная переменная, которая содержала это значение:% APPDATA% npm. Я удалил его, и проблема исчезла!


0

S.vaysrub
20 Фев 2018 в 18:58

Шаги 1 в пользовательской переменной и системной переменной

  C:Program Filesnodejs

Затем проверьте оба node -v
и npm -v
затем попробуйте обновить npm i -g npm


1

Mohammed_Alreai
9 Мар 2020 в 10:19

Если после успешной установки npm и вы хотите установить VueJS, то это то, что вам следует сделать

После выполнения следующей команды (от имени администратора)

npm install --global vue-cli

Он поместит vue.cmd в следующий каталог C:UsersYourUserNameAppDataRoamingnpm

Вы увидите это в своем каталоге.

Теперь, чтобы использовать vue как команду в cmd. Откройте cmd от имени администратора и выполните следующую команду.

setx /M path "%path%;%appdata%npm"

Теперь перезапустите cmd и снова запустите vue. Он должен работать нормально, и тогда вы сможете приступить к разработке с помощью VueJS.

Надеюсь, это поможет.


1

Premium Ayodele
19 Дек 2019 в 22:30

Я делал это в Windows 10,

  1. Искать переменные среды в поиске Windows
  2. В результате появится опция «Изменить системные переменные среды».
  3. Откройте его, выберите «Путь» и нажмите «Изменить», затем нажмите «Создать», добавьте путь к вашей папке nodeJS, т.е. на моем компьютере он установлен в c:programfilesnodejsnode_modulesnpmbin
  4. После добавления нажмите «ОК», затем закройте

Теперь вы можете написать свою команду в командной строке или в PowerShell.

Если вы используете WIndows 10, выберите PowerShell с богатым пользовательским интерфейсом.


2

Szabolcs Páll
1 Апр 2019 в 07:37

Измените путь для узла js в переменной окружения.

setting environment variable


2

Machavity
21 Окт 2018 в 02:34

Это сработало для меня: 1. npm root -g (чтобы увидеть, что текущий npm установлен) 2. npm config set prefix (для изменения пути)


4

marty
19 Дек 2017 в 09:11

У меня проблема с nodejs. Я пытаюсь установить библиотеку ember.js через командную строку. Когда я запускаю команду «npm install», этот журнал появляется:

0 info it worked if it ends with ok 1 verbose cli [ 'C:Program Filesnodejs\node.exe', 1 verbose cli 'C:Program Filesnodejsnode_modulesnpmbinnpm-cli.js', 1 verbose cli 'install' ] 2 info using npm@2.11.3 3 info using node@v0.12.7 4 verbose config Skipping project config: C:UsersAntonio/.npmrc. (matches userconfig) 5 verbose readDependencies loading dependencies from C:UsersAntoniopackage.json 6 error install Couldn't read dependencies 7 verbose stack Error: ENOENT, open 'C:UsersAntoniopackage.json' 7 verbose stack at Error (native) 8 verbose cwd C:UsersAntonio 9 error Windows_NT 6.3.9600 10 error argv "C:Program Filesnodejs\node.exe" "C:Program Filesnodejsnode_modulesnpmbinnpm-cli.js" "install" 11 error node v0.12.7 12 error npm v2.11.3 13 error path C:UsersAntoniopackage.json 14 error code ENOPACKAGEJSON 15 error errno -4058 16 error package.json ENOENT, open 'C:UsersAntoniopackage.json' 16 error package.json This is most likely not a problem with npm itself. 16 error package.json npm can't find a package.json file in your current directory. 17 verbose exit [ -4058, true ]

Я посетил NPM Troubleshooting, но я не могу найти решение (я попробовал три варианта, но ничего не случилось). Просто сказать: в AppData/Roaming еще есть папка с именем «npm».

Понравилась статья? Поделить с друзьями:
  • Npm install no such file or directory windows
  • Npm install global production windows build tools зависает
  • Npm install g jshint windows как установить
  • Npfs sys синий экран windows 10
  • Npf sys windows 10 как удалить