pnpm not installing dev dependencies correctly(?)

864 Views Asked by At

I'm trying to migrate some all projects to a monorepo with pnpm.
Here's the structure of my repo:

project1/
project2/
package.json
pnpm-workspace.yaml
...

Here's the content of project1/package.json

...
"devDependencies": {
  "grunt": "^1.5.3",
  "grunt-babel": "^8.0.0",
  "grunt-cli": "^1.4.3",
  "grunt-contrib-watch": "^1.1.0",
  "grunt-exec": "^3.0.0",
  "grunt-karma": "^4.0.2",
  "istanbul-combine": "^0.3.0",
  "jasmine": "^4.5.0",
  "karma": "^6.4.1",
  "karma-chrome-launcher": "^3.1.1",
  "karma-cli": "^2.0.0",
  "karma-coverage": "^2.2.0",
  "karma-jasmine": "^5.1.0",
  "karma-replacer-preprocessor": "0.0.2",
  "karma-spec-reporter": "0.0.36"
}

project1/karma.conf.js

module.exports = function (config) {
  config.set({
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: ['*/*.js'],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      './*.js': ['replacer', 'coverage'],
    },

    replacerPreprocessor: {
      replacer (file, content) { /* ... */ },
    },

    // ...
  });
};

If I run cd project1 && npm i, I can run the tests from the root with npm --prefix project1 run test.

However, if I remove the node_modules and use pnpm i instead of npm i, when i run the tests, I get a few errors:

  1. Cannot load "replacer", it is not registered!
    and
  2. Server start failed on port 9876: Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)

I tried pnpm i --shamefully-hoist and adding auto-install-peers=true to ./npmrc but in vain... How can I fix this?

0

There are 0 best solutions below