Skip to content

Error: Cannot find module 'mkdirp' when using preact-cli with Volta #1105

@green-martian-chef

Description

@green-martian-chef

Do you want to request a feature or report a bug?
Bug

What is the current behaviour?
I use volta to manage my stack. I tried to install preact-cli using volta but I got this error:

internal/modules/cjs/loader.js:985
  throw err;
  ^

Error: Cannot find module 'mkdirp'
Require stack:
- /opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/commands/create.js
- /opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/commands/index.js
- /opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/commands/create.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/commands/index.js:2:18)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/commands/create.js',
    '/opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/commands/index.js',
    '/opt/volta/tools/image/packages/preact-cli/3.0.0-rc.10/lib/index.js'
  ]
}

If the current behaviour is a bug, please provide the steps to reproduce.

  • Install volta: curl https://get.volta.sh | bash
  • Install preact-cli using volta: volta install preact-cli@rc
  • Use preact command: preact -h

What is the expected behaviour?
No error when running

If this is a feature request, what is motivation or use case for changing the behaviour?

Please mention other relevant information.
This bug happens because preact-cli lists mkdirp as a dev-dependency but actually needs mkdirp to run in production and volta only install package dependencies, not dev-dependencies. Explicit list mkdirp as dependency fix the bug.

Please paste the results of preact info here.
Environment Info:
System:
OS: Linux 5.3 elementary OS 5.1.2 Hera
CPU: (6) x64 AMD FX(tm)-6300 Six-Core Processor
Binaries:
Node: 12.16.1 - /opt/volta/tools/image/node/12.16.1/6.13.4/bin/node
Yarn: 1.22.4 - /opt/volta/tools/image/yarn/1.22.4/bin/yarn
npm: 6.13.4 - /opt/volta/tools/image/node/12.16.1/6.13.4/bin/npm
Browsers:
Firefox: 74.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions