0

I have the following source tree:

/project/
  |- package.json
  |- package-lock.json
  |- tsconfig.json
  |- node_modules
  |- src/
      |- moduleA
          |- package.json
          |- tsconfig.json
          |- index.ts
          |- classA.ts
      |- moduleB
          |- package.json
          |- tsconfig.json
          |- classB.ts

moduleA package.json:

{
  "name": "core",
  "version": "1.0.0",
  "description": "Web API Core module",
  "license": "ISC",
  "scripts": {
    "build": "tsc --project tsconfig.build.json && npm run rollup",
    "build:watch": "nodemon -e ts --exec \"npm run build\" --ignore build/** --ignore tests/**",
    "rollup": "rollup -c"
  },
  "dependencies": {
    "async": "^3.2.4",
    "express": "^4.18.1"
  },
  "devDependencies": {
    "@rollup/plugin-typescript": "^8.3.4",
    "@types/express": "^4.17.13",
    "@types/node": "^18.6.4",
    "nodemon": "^2.0.19",
    "rollup": "^2.77.2",
    "rollup-plugin-dts": "^4.2.2",
    "tslib": "^2.4.0",
    "typescript": "^4.7.4"
  },
  "keywords": [],
  "main": "index.js",
  "types": "build/src/index.d.ts",
  "engines": {
    "node": ">=18.4.0"
  }
}

ROOT package.json:

{
  "name": "project",
  "version": "1.0.0",
  "private": true,
  "exports": "./bin/www.js",
  "type": "module",
  "scripts": {
  },
  "workspaces": [
    "src/moduleA",
    "src/moduleB"
  ]
}

I run npm i inside each of the module's folder and expect package-lock.json and node_modules generated but it isn't. There is no package-lock.json and node_modules folder inside moduleA and moduleB.

To confirm, I remove package-lock.json and node_modules at the ROOT of the source tree and run npm i inside one of the modules, the artefacts are generated in the ROOT of the source tree.

Is this the right expected behaviour?

$ npm config ls -l|grep package-lock
npm WARN config This command does not support workspaces.
format-package-lock = true 
package-lock = true 
package-lock-only = false 

npm version: 8.15.0

node version: 18.4.0

Running rm -rf node-modules && npm i and npm install --package-lock does not resolve the issue.

Kok How Teh
  • 3,298
  • 6
  • 47
  • 85

0 Answers0