Problem with npm install... npm ERR! code E400 - node.js

Firstly I installed the latest version of angular cli. Then when I tried to downgrade to 7.3.3 there was an error: 400 Bad Request - GET https://github.com/. Also I can not install anything with npm install like node-sass etc. So I unistalled nodejs and tried to install again angular cli, but the same error appeared. Maybe I have changed any configuration.
CMD
C:\Windows\system32>node -v
v12.17.0
C:\Windows\system32>npm install -g #angular/cli
npm ERR! code E400
npm ERR! 400 Bad Request - GET https://github.com/
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XXXX\AppData\Roaming\npm-cache\_logs\2020-06-01T10_49_37_560Z-debug.log
Logs
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 'install',
1 verbose cli '-g',
1 verbose cli '#angular/cli'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.17.0
4 verbose npm-session bc2383db262e35f5
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 400 https://github.com/ 506ms
8 silly fetchPackageMetaData error for #angular/cli#latest 400 Bad Request - GET https://github.com/
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 543ms
11 verbose stack Error: 400 Bad Request - GET https://github.com/
11 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:104:15
11 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
12 verbose statusCode 400
13 verbose pkgid #angular/cli#latest
14 verbose cwd C:\Windows\system32
15 verbose Windows_NT 10.0.17763
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "#angular/cli"
17 verbose node v12.17.0
18 verbose npm v6.14.4
19 error code E400
20 error 400 Bad Request - GET https://github.com/
21 verbose exit [ 1, true ]

1.>Go to your this location
C:\Users\{your user name or ID}
2.> open .npmrc & Remove all content from .npmrc file.
3.>reopen your new command prompt
4.>again run the code , will work.

you must enable developer mode first in windows 10
setting
update & security
for developers
and enable developer mode

Related

I can't install react using npx create-react-app is this aNodist the issue?

I've received the following in the debug log. I'm looking to npx create-react-app. The terminal is returning
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2022-06-07T14_57_21_064Z-debug.log
Install for [ 'create-react-app#latest' ] failed with code 1
This is the debug file...
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files (x86)\\Nodist\\v-x64\\18.1.0\\node.exe',
1 verbose cli 'C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npx\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'create-react-app#latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\User\\AppData\\Roaming\\npm-cache\\_npx\\50292',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json'
1 verbose cli ]
2 info using npm#5.1.0
3 info using node#v18.1.0
4 verbose npm-session 56a59e1a77678c6d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/create-react-app 102ms (from cache)
8 silly pacote tag manifest for create-react-app#latest fetched in 165ms
9 verbose stack TypeError: cb.apply is not a function
9 verbose stack at C:\Program Files (x86)\Nodist\bin\node_modules\npx\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
9 verbose stack at FSReqCallback.oncomplete (node:fs:204:5)
10 verbose cwd C:\Users\User\Websites\react
11 verbose Windows_NT 10.0.19044
12 verbose argv "C:\\Program Files (x86)\\Nodist\\v-x64\\18.1.0\\node.exe" "C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npx\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-react-app#latest" "--global" "--prefix" "C:\\Users\\User\\AppData\\Roaming\\npm-cache\\_npx\\50292" "--loglevel" "error" "--json"
13 verbose node v18.1.0
14 verbose npm v5.1.0
15 error cb.apply is not a function
16 verbose exit [ 1, true ]
I'm using the latest beta version of Node, so I'll try to go back to the latest stable version. If that doesn't work, I'll try to re-download node away from nodist..
If you have any other thoughts or suggestions Perhaps there is a hint in the debug log, then I'd be glad to hear them.
According to the discussion under github https://github.com/facebook/create-react-app/discussions/10173#discussioncomment-142156
you need to
npm rm -g create-react-app
npm install create-react-app
npx create-react-app my-app
After deleting the Nodist version manager. I installed nvm and I'm now able to get npx to work without a problem. I think the issue for me was that I was using the nodist version manager.
Highly recommend checking out nvm here if you get similar issues.
https://github.com/coreybutler/nvm-windows/wiki

An unexpected error occurred: "EPERM: operation not permitted"

I have installed ReactJS to work on some project but this mistakes are making me sick.
First error appear when I tried to add package for my project.
So , I used :
yarn add #material-ui/icons
and after that It was fetching.
And I got this error message on the terminal line :
error An unexpected error occurred: "EPERM: operation not permitted, unlink 'C:\\React\\MyProject\\node_modules\\node-sass\\vendor\\win32-x64-93\\bindiinfo Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
I found some solutions and wanted to try. Whenever I try to use install command, it does not let me.
It gives this error
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XXXXXX\AppData\Roaming\npm-cache\_logs\2021-11-14T00_08_12_781Z-debug.log
enter code here
and whenever I click this error log, here is what I see.
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:\\Users\\XXXXXXXX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'yarn'
1 verbose cli ]
2 info using npm#5.3.0
3 info using node#v16.13.0
4 verbose npm-session 95556b4f7a104717
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/yarn 188ms
8 http fetch GET 200 https://registry.npmjs.org/yarn/-/yarn-1.22.17.tgz 120ms
9 silly pacote tag manifest for yarn#latest fetched in 352ms
10 verbose stack TypeError: cb.apply is not a function
10 verbose stack at C:\Users\XXXXXXX\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
10 verbose stack at FSReqCallback.oncomplete (node:fs:199:5)
11 verbose cwd D:\React\projem
12 verbose Windows_NT 10.0.19043
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\XXXXXXXX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "yarn"
14 verbose node v16.13.0
15 verbose npm v5.3.0
16 error cb.apply is not a function
17 verbose exit [ 1, true ]
Please help me or I'll drive crazy so soon!
All the best everyone and THANK YOU! for your help.
Please stop the development server and install or add the packages.
I faced same issue when I tried to install the blueprint package using yarn, I solved it by using npm package manager (npm install)

Npm cannot install packages with npm init

I'm trying to install next js with command below:
$c:/Desktop/next: npm init next-app nextjs-blog
Which gave me an error
npm ERR! Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
Note: My Users is C:/Users/Sunita Dahal but it seems to be looking inside of Dahal. But I'm able to install global packages.
reinstalling & cleaning cache doesnt work work me
Here is the complete error log:
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 'install',
1 verbose cli 'create-next-app#latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\Sunita',
1 verbose cli 'Dahal\\AppData\\Roaming\\npm-cache\\_npx\\14636',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.3
4 verbose npm-session a7314bdab23f336e
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Dahal\AppData\Roaming\npm-cache\_npx\14636 Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
8 http fetch GET 304 https://registry.npmjs.org/create-next-app 167ms (from cache)
9 silly pacote tag manifest for create-next-app#latest fetched in 190ms
10 timing stage:rollbackFailedOptional Completed in 1ms
11 timing stage:runTopLevelLifecycles Completed in 204ms
12 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\Sunita Dahal\Desktop\next\Dahal\AppData\Roaming\npm-cache\_npx\14636\package.json'
13 verbose cwd C:\Users\Sunita Dahal\Desktop\next
14 verbose Windows_NT 10.0.18362
15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-next-app#latest" "--global" "--prefix" "C:\\Users\\Sunita" "Dahal\\AppData\\Roaming\\npm-cache\\_npx\\14636" "--loglevel" "error" "--json"
16 verbose node v12.16.3
17 verbose npm v6.14.4
18 error code ENOLOCAL
19 error Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
20 verbose exit [ 1, true ]
SOLUTION
Changing my cache path fixed the issue for me.
npm config set cache C:\tmp\nodejs\npm-cache --global
more at: https://github.com/zkat/npx/issues/146
So the command npm init will initialize a new project and generate a package.json file that contains project-related information. The command can be run anywhere. Use npm init when you want to create a new project of your own.
However, npm install, or npm i for short, will install project-related dependencies in the package.json file in an existing project directory. You can also use npm i package_name_here to install new package to your current project. The command must be run in an existing project directory with a valid package.json

Got 400 error while installing Angular CLI on windows 10 behind proxy server

I just started to learn angular and need to install Angular CLI on my PC (Windows 10) behind a proxy server. My node version is v12.13.1 and npm version is 6.12.1.
I went to the Settings --> Network & Internet --> Proxy and copy the whole value in Script address field and update the config file with that value:
https-proxy=Script address value
proxy=Script address value
Now, when I run npm install -g #angular/cli I get this error below:
npm ERR! 400 Bad Request - GET
https://registry.npmjs.org/#angular%2fcli
and this is log file:
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 'install',
1 verbose cli '-g',
1 verbose cli '#angular/cli'
1 verbose cli ]
2 info using npm#6.12.1
3 info using node#v12.13.1
4 verbose npm-session 273f364019e6cde2
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 400 https://registry.npmjs.org/#angular%2fcli 643ms
8 silly fetchPackageMetaData error for #angular/cli#latest 400 Bad Request - GET https://registry.npmjs.org/#angular%2fcli
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 968ms
11 verbose stack Error: 400 Bad Request - GET https://registry.npmjs.org/#angular%2fcli
11 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:104:15
11 verbose stack at processTicksAndRejections (internal/process/task_queues.js:93:5)
12 verbose statusCode 400
13 verbose pkgid #angular/cli#latest
14 verbose cwd C:\Program Files\nodejs
15 verbose Windows_NT 10.0.18362
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "#angular/cli"
17 verbose node v12.13.1
18 verbose npm v6.12.1
19 error code E400
20 error 400 Bad Request - GET https://registry.npmjs.org/#angular%2fcli
21 verbose exit [ 1, true ]
Could you please let me know what am I missing here and how I can resolve the issue.
Thanks for your help.
UPDATE (Solution)
Thanks for your comments. I checked the URL and changed my proxy to localhost and it works. The config file looks as below:
proxy=http://localhost:8888/proxy.pac
https-proxy=http://localhost:8888/proxy.pac
http-proxy=http://localhost:8888/proxy.pac
registry=http://registry.npmjs.org/
I used localhost instead of our proxy URL and it resolved the issue. below is my config file:
proxy=http://localhost:8888/proxy.pac
https-proxy=http://localhost:8888/proxy.pac
http-proxy=http://localhost:8888/proxy.pac
registry=http://registry.npmjs.org/

mocha installation error: Unexpected end of input

I'm trying to install mocha on my windows 10 but I'm getting this error on the terminal
$npm install mocha#3.0.0 --save-dev
npm ERR! Unexpected end of input at 1:19983
npm ERR! a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NS\AppData\Roaming\npm-cache\_logs\2017-06-24T21_47_36_363Z-debug.log
this is the log file content
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\NS\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'mocha#3.0.0',
1 verbose cli '--save-dev' ]
2 info using npm#5.0.2
3 info using node#v6.10.2
4 silly install loadCurrentTree
5 silly install readLocalPackageData
6 http fetch GET 200 https://registry.npmjs.org/mocha 34ms (from cache)
7 silly fetchPackageMetaData error for mocha#3.0.0 Unexpected end of input at 1:19983
7 silly fetchPackageMetaData a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
7 silly fetchPackageMetaData ^
8 verbose stack SyntaxError: Unexpected end of input at 1:19983
8 verbose stack a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
8 verbose stack ^
8 verbose stack at SyntaxError (native)
8 verbose stack at Object.parseJSON (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\node_modules\jju\lib\parse.js:745:13)
8 verbose stack at parse (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\index.js:10:13)
8 verbose stack at consumeBody.call.then.buffer (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
8 verbose stack at process._tickCallback (internal/process/next_tick.js:109:7)
9 verbose cwd C:\Users\NS\node-test
10 verbose Windows_NT 10.0.15063
11 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\NS\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "mocha#3.0.0" "--save-dev"
12 verbose node v6.10.2
13 verbose npm v5.0.2
14 error Unexpected end of input at 1:19983
14 error a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
14 error ^
15 verbose exit [ 1, true ]
if you are using the latest version of node
try downgrading to the LTS version
//
sudo npm install n -g
sudo n lts
if you are using it in local then use command "npm cache clean --force" to clear cache. Then run your command it will work

Resources