skip to Main Content

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:



> [email protected] install
> npm i


> [email protected] install
> npm i


> [email protected] install
> npm i


> [email protected] install
> npm i


> [email protected] install
> npm i


> [email protected] install
> npm i


> [email protected] install
> npm i


> [email protected] 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:UsersNiklasDesktopProjectLearn4FunWebwwwroot
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersNiklasAppDataLocalnpm-cache_logs2022-11-19T21_35_56_965Z-debug.log
npm ERR! code 1
npm ERR! path C:UsersNiklasDesktopProjectLearn4FunWebwwwroot
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersNiklasAppDataLocalnpm-cache_logs2022-11-19T21_35_56_990Z-debug.log
npm ERR! code 1
npm ERR! path C:UsersNiklasDesktopProjectLearn4FunWebwwwroot
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersNiklasAppDataLocalnpm-cache_logs2022-11-19T21_35_57_010Z-debug.log
npm ERR! code 1
npm ERR! path C:UsersNiklasDesktopProjectLearn4FunWebwwwroot
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersNiklasAppDataLocalnpm-cache_logs2022-11-19T21_35_57_032Z-debug.log
npm ERR! code 1
npm ERR! path C:UsersNiklasDesktopProjectLearn4FunWebwwwroot
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.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 [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:Program FilesMicrosoft Visual Studio2022CommunityMSBuildMicrosoftVisualStudioNodeJsnode_modulesnpmnpmrc 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:UsersNiklas.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:Program FilesMicrosoft Visual Studio2022CommunityMSBuildMicrosoftVisualStudioNodeJsetcnpmrc 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:UsersNiklasAppDataLocalnpm-cache_logs2022-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.

2

Answers


  1. Chosen as BEST ANSWER

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


  2. Did you set the path to npm?

    In your windows environment variable

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search