-1

Recently I have had some problems regarding basic npm commands.

I have the following package.json:

{
  "name": "bundle",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "author": "",
  "license": "ISC",
  "scripts": {
    "install": "npm i",
    "bundle": "webpack",
    "watch": "webpack --mode=development --watch"
  },
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.19.6",
    "@babel/preset-env": "^7.20.2",
    "@babel/preset-react": "^7.18.6",
    "@babel/preset-typescript": "^7.18.6",
    "@types/react": "^18.0.25",
    "@types/react-dom": "^18.0.8",
    "babel-loader": "^9.1.0",
    "css-loader": "^6.7.1",
    "html-webpack-plugin": "^5.5.0",
    "sass": "^1.56.0",
    "sass-loader": "^13.1.0",
    "source-map-loader": "^4.0.1",
    "style-loader": "^3.3.1",
    "ts-loader": "^9.4.1",
    "typescript": "^4.8.4",
    "webpack": "^5.74.0",
    "webpack-cli": "^4.10.0"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}


I get the following when i try to install:



> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i


> bundle@1.0.0 install
> npm i

'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_56_965Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_56_990Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_57_010Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_57_032Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

One of the log files. (this is when it runs from VS 2022

0 verbose cli [
0 verbose cli   'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs\\node.exe',
0 verbose cli   'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'prefix',
0 verbose cli   '-g'
0 verbose cli ]
1 info using npm@8.3.1
2 info using node@v16.14.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:C:\Users\Niklas\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 6ms
18 timing npm:load:configload Completed in 6ms
19 timing npm:load:setTitle Completed in 0ms
20 timing config:load:flatten Completed in 2ms
21 timing npm:load:display Completed in 2ms
22 verbose logfile C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_17_05_361Z-debug-0.log
23 timing npm:load:logFile Completed in 4ms
24 timing npm:load:timers Completed in 0ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load Completed in 13ms
27 timing command:prefix Completed in 1ms
28 verbose exit 0
29 timing npm Completed in 171ms
30 info ok

I have tried uninstall / re install node/npm (different versions). Removed npm cache. Removed all npm folders on pc. Restarted pc.

Sensei Munk
  • 126
  • 1
  • 9
  • That's not a problem with node.js, npm, webpack or npm-install. It's problem with your operating system and environment. `npm` can't be found in `PATH`. `'npm' is not recognized as an internal or external command, operable program or batch file.` should be pretty clear. Have you tried searching for this error message? – jabaa Nov 19 '22 at 21:52
  • Does this answer your question? ['npm' is not recognized as internal or external command, operable program or batch file](https://stackoverflow.com/questions/20992723/npm-is-not-recognized-as-internal-or-external-command-operable-program-or-bat) – jabaa Nov 19 '22 at 21:54
  • Does this answer your question? ['npm' is not recognized as an internal or external command, operable program or batch file after installing Node.js - Windows](https://stackoverflow.com/questions/59679185/npm-is-not-recognized-as-an-internal-or-external-command-operable-program-or) – jabaa Nov 19 '22 at 21:55
  • Does this answer your question? ['npm' is not recognized as an internal or external command, operable program or batch file in laravel 6.0](https://stackoverflow.com/questions/57863144/npm-is-not-recognized-as-an-internal-or-external-command-operable-program-or) – jabaa Nov 19 '22 at 21:56
  • I have set the environment variable. node Welcome to Node.js v16.12.0. – Sensei Munk Nov 19 '22 at 22:05
  • Apparently, you didn't set it correctly. What do you get for `where npm`? – jabaa Nov 19 '22 at 22:06
  • The path point directly to the nodejs repo... what do you mean by "where npm"? – Sensei Munk Nov 19 '22 at 22:15
  • Type `where npm` into your terminal and press enter. It shows you whether it can be found. What do you mean by node repo? Have you cloned the GitHub repo? The node repo doesn't contain a `npm` executable. Have you built the repo? – jabaa Nov 19 '22 at 22:19

2 Answers2

-1

Did you set the path to npm?

In your windows environment variable

  • The environment variable is set and the npm.cmd is inside the nodejs folder. I have deleted everything inside package.json / even deleted it. Executed "npm init" again and it still fails. – Sensei Munk Nov 19 '22 at 22:07
-1

Deleted everything. Ran npm init and copied exact same package reference into the new package.json suddenly it worked...

Sensei Munk
  • 126
  • 1
  • 9
  • _"Not reproducible or was caused by a typo"_ is a close reason. The question should be closed/deleted, not answere. – jabaa Nov 19 '22 at 23:30