Cli: [BUG] "npm run" appears not to work

Created on 1 Dec 2019  ·  7Comments  ·  Source: npm/cli

What / Why


"npm run" appears not to work - generates no output.

When

On a command line (Windows "CMD.EXE")

Where

Windows Home (Version 1909)
node -v: v12.13.1
npm -v: 6.12.1

How

Current Behavior

npm run generates no output

Steps to Reproduce

On a command line (Windows "CMD.EXE"):
md npm-run-issue
cd npm-run-issue
npm init

Edit contents of package.json:

{
  "name": "npm-run-issue",
  "version": "1.0.0",
  "description": "Minimal reproduction of npm run issue",
  "main": "index.js",
  "scripts": {
    "echo": "echo 'run' works!"
  },
  "author": "",
  "license": "ISC"
}

npm run echo

No output (at all) is generated.

Expected Behavior

Output should be similar to that from "yarn run":
yarn run v1.9.4
$ echo 'run' works!
'run' works!
Done in 0.12s.

References

The issue can be reproduced locally with this GitHub repository:
https://github.com/snerks/npm-run-issue

Most helpful comment

@ljharb - thanks for resolving my issue!

All 7 comments

Do you have “ignore-scripts” set in your global npm config?

@ljharb

I just checked the global config folder:
C:\Users\[UserName]\AppData\Roaming\npm\etc\npmrc

In my case, no such folder existed.

I then checked the per-user config file:
C:\Users\[UserName]\.npmrc

To my surprise, the file contained this (as you suspected):
ignore-scripts=true

I set it to this:
ignore-scripts=false

Then retried:
npm run echo:

> [email protected] echo C:\D\SamplesNode\npm-run-issue
> echo 'run' works!

'run' works!

Question: Any idea how this setting gets made? I'm pretty sure I didn't do it (as far as I know).

You probably followed some paranoid tutorial that suggested disabling that setting systemwide with npm config -g ignore-scripts false or something.

I'm having the same issue.
npm install neither upgrade nor downgrade the package works.
npm install package {package-name}@{version} works.

@jeffminsungkim thats a different issue, i think.

@ljharb - thanks for resolving my issue!

@ljharb thanks for the solution
For linux users>
~/.npmrc open that file and set ignore-scripts=false

Was this page helpful?
0 / 5 - 0 ratings