Skip to content Skip to sidebar Skip to footer

Unknown Command: "pkg" When Running Npm Command

I am facing the issue in running this command npm pkg set name=foo3 Unknown command: 'pkg' To see a list of supported npm commands, run: npm help The documentation says that it

Solution 1:

7.20.3 (latest as of this post) has pkg available

$ npm --version
7.20.3
$ npm pkg set name=testpkg
$ cat package.json
{
  "name": "testpkg",
...
npm i -g npm

To update to latest.


Solution 2:

I just tried and it worked

flakerimi$ npm pkg set name=foo3
flakerimi$ npm pkg get
{
  "name": "foo3",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Maybe it has to do with your version of NPM or npm installation, Can you reinstall it, try from stable source.


Solution 3:

npm install -g npm is working on my side


Solution 4:

To make sure it works for all users, this is what I am doing right now

npx -y npm@latest pkg set name=${repoName} 

Post a Comment for "Unknown Command: "pkg" When Running Npm Command"