简体   繁体   中英

Npm can't install any packages

I need some help because i can't install any npm packages. When i try to install something i get this error.

在此处输入图像描述

My node version is 6.11.0 and npm version is 3.10.10.

npm-debug.log :

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   'run',
1 verbose cli   'server:dev',
1 verbose cli   '--',
1 verbose cli   '--hot',
1 verbose cli   '--proxy-requests' ]
2 info using npm@3.10.10
3 info using node@v6.11.0
4 verbose stack Error: missing script: server:dev
4 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:151:19)
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:61:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:356:5
4 verbose stack     at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:320:45)
4 verbose stack     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:354:3)
4 verbose stack     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:124:5)
4 verbose stack     at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:295:20)
4 verbose stack     at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:366:13)
5 verbose cwd C:\Users\Scyli\Desktop\angular
6 error Windows_NT 10.0.14393
7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "server:dev" "--" "--hot" "--proxy-requests"
8 error node v6.11.0
9 error npm  v3.10.10
10 error missing script: server:dev
11 error If you need help, you may report this error at:
11 error     <https://github.com/npm/npm/issues>
12 verbose exit [ 1, true ]

Please help me solve this problem.

已解决:32 位 NodeJs 完全解决了我的问题。

This commands solve same problem

npm install -g npm
npm cache clean
npm update
npm install

I tried many different suggestions finding a solution. For reference: I'm working in Goorm online IDE.

In the end, simply reinstalling npm in the root directory did the trick. I ran:

sudo npm install npm -g

and afterwards I was able to install packages as normal again.

my problem solves after editing npm-config file

for edit that file npm config edit

my npm config file

;;;;
; npm userconfig file
; this is a simple ini-formatted file
; lines that start with semi-colons are comments.
; read `npm help config` for help on the various options
;;;;


;;;;
; all options with default values
;;;;
; access=null

; allow-same-version=false

; always-auth=false

; also=null

; auth-type=legacy

; bin-links=true

; browser=null

; ca=null

; cafile=undefined

; cache=C:\Users\Admin\AppData\Roaming\npm-cache

; cache-lock-stale=60000

; cache-lock-retries=10

; cache-lock-wait=10000

; cache-max=null

; cache-min=10

; cert=null

; cidr=null

; color=true

; depth=null

; description=true

; dev=false

; dry-run=false

; editor=notepad.exe

; engine-strict=false

; force=false

; fetch-retries=2

; fetch-retry-factor=10

; fetch-retry-mintimeout=10000

; fetch-retry-maxtimeout=60000

; git=git

; git-tag-version=true

; commit-hooks=true

; global=false

; globalconfig=C:\Users\Admin\AppData\Roaming\npm\etc\npmrc

; global-style=false

; group=0

; ham-it-up=false

; heading=npm

; if-present=false

; ignore-prepublish=false

; ignore-scripts=false

; init-module=C:\Users\Admin\.npm-init.js

; init-author-name=

; init-author-email=

; init-author-url=

; init-version=1.0.0

; init-license=ISC

; json=false

; key=null

; legacy-bundling=false

; link=false

; local-address=undefined

; loglevel=notice

; logs-max=10

; long=false

; maxsockets=50

; message=%s

; metrics-registry=null

; node-options=null

; node-version=8.11.2

; offline=false

; onload-script=null

; only=null

; optional=true

; otp=0

; package-lock=true

; package-lock-only=false

; parseable=false

; prefer-offline=false

; prefer-online=false

; prefix=C:\Program Files\nodejs

; production=false

; progress=true

; proxy=null

; https-proxy=null

; user-agent=npm/{npm-version} node/{node-version} {platform} {arch}

; read-only=false

; rebuild-bundle=true

; registry=https://registry.npmjs.org/

; rollback=true

; save=true

; save-bundle=false

; save-dev=false

; save-exact=false

; save-optional=false

; save-prefix=^

; save-prod=false

; scope=

; script-shell=null

; scripts-prepend-node-path=warn-only

; searchopts=

; searchexclude=null

; searchlimit=20

; searchstaleness=900

; send-metrics=false

; shell=C:\Windows\system32\cmd.exe

; shrinkwrap=true

; sign-git-tag=false

; sso-poll-frequency=500

; sso-type=oauth

; strict-ssl=true

; tag=latest

; tag-version-prefix=v

; timing=false

; tmp=C:\Users\Admin\AppData\Local\Temp

; unicode=false

; unsafe-perm=true

; usage=false

; user=0

; userconfig=C:\Users\Admin\.npmrc

; umask=0

; version=false

; versions=false

; viewer=browser

; _exit=true

; globalignorefile=C:\Users\Admin\AppData\Roaming\npm\etc\npmignore

I was getting leaf signature err,so i solved it by: //first type this

npm config set strict-ssl false

//and then

npm config set NODE_TLS_REJECT_UNAUTHORIZED 0

and after that try to install the packages.

I guess you need to clear your cache and update your npm from the root of your nodejs installation folder.

To do that, Navigate to your, C:\Program Files\nodejs\npm directory and issue the below command,

npm cache clean

After than update your npm using the below command,

npm update

Hope this helps!

清理缓存也对我有用

In my case, I was cloning a GIT repo at work that other developers were using and building without issue. Tried all these solutions but the ultimate fix was downgrading my version of npm to an earlier version. Very simple, I know, but this line of code may just save you a day of debugging if your output is different than other devs on your team!

npm -v

If you are a windows user run cmd as administrator and then install packages. It worked for me while installing express via npm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM