Skip to content

The 'npm run start' command exits with file not found error #1867

Description

@OnkarRuikar

Summary

The npm run start is not starting the local server.

Problem

I am getting the following error every time I pull remote and run the command:

$ npm run start
npm notice run @mdn/content@1.0.0 start
npm notice run npm run --silent info:fred && npm run up-to-date-check && env-cmd --silent cross-env CONTENT_ROOT=files NODE_ENV=production FRED_PLAYGROUND_LOCAL=true FRED_PLAYGROUND_PORT=5043 FRED_PORT=5042 FRED_WRITER_MODE=true fred server

🐥 This command is using Fred: https://github.com/mdn/fred
🐞 Please report issues here:  https://github.com/mdn/fred/issues/new?template=bug.yml

npm notice run @mdn/content@1.0.0 up-to-date-check
npm notice run node scripts/up-to-date-check.js
[rari] /bin/sh: 1: /home/userme/GitHub/mdn/content/node_modules/@mdn/rari/bin/rari: not found
[rari] "/home/userme/GitHub/mdn/content/node_modules/@mdn/rari/bin/rari" serve -vv exited with code 127
--> Sending SIGTERM to other processes..
[server] node "/home/userme/GitHub/mdn/content/node_modules/@mdn/fred/server.js" exited with code SIGTERM
All tasks completed successfully.
node:internal/process/promises:392
      new UnhandledPromiseRejection(reason);
      ^

UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "[object Array]".
    at throwUnhandledRejectionsMode (node:internal/process/promises:392:7)
    at processPromiseRejections (node:internal/process/promises:475:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:106:37) {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v24.20.0

From the logs, and I checked manually, the node_modules/@mdn/rari/bin/rari file is not being created by npm install and npm ci executions.

This is because:

Starting with npm v12, GitHub implemented a major security change: all lifecycle scripts (like preinstall, install, and postinstall) are turned off by default to block malicious supply-chain code execution.

The following scripts should be added to allow list:

$ npm install-scripts ls
5 packages have install scripts blocked because they are not covered by allowScripts:
  @mdn/rari@0.2.34 (postinstall: node ./lib/postinstall.js)
  gifsicle@5.3.0 (postinstall: node lib/install.js)
  lefthook@2.1.12 (postinstall: node postinstall.js)
  mozjpeg@8.0.0 (postinstall: node lib/install.js)
  pngquant-bin@9.0.0 (postinstall: node lib/install.js)

Run `npm install-scripts approve <pkg>` to allow, or `npm install-scripts deny <pkg>` to deny.

Solution

Either one of the following:

  1. Add the following to package.json:
     "allowScripts": {
        "@mdn/rari": true,
        "gifsicle": true,
        "lefthook": true,
        "mozjpeg": true,
        "pngquant-bin": true
      }
    
  2. Add the following to the .npmrc file:
allow-scripts=@mdn/rari,gifsicle,lefthook,mozjpeg,pngquant-bin
  1. Update the contributing document to add the above line to the global config ~/.npmrc file.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p1We will address this soon and will provide capacity from our team for it in the next few releases.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions