vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.39k stars 1.84k forks source link

[turborepo] prune - npm local filesystem package not working #5332

Closed ph55 closed 11 months ago

ph55 commented 1 year ago

What version of Turborepo are you using?

1.10.3

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Describe the Bug

When one of the application in the workspace has local folder as a package - npm install will fail on "pruned" package-lock.json with error:

npm ERR! Cannot read properties of undefined (reading 'extraneous')

Expected Behavior

Turborepo should work with local folder npm package.

To Reproduce

Reproduction Repo

No response

capkakitiga commented 1 year ago

Any update?

varl commented 1 year ago

We have the same issue on Linux platforms.

node v18.13.0
npm v8.19.3
varl commented 1 year ago

Not sure about any unintended consequences, but npm update before the npm install command seems to workaround the issue.

From our Dockerfile:

COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json

# update as a workaround for:
#   https://github.com/vercel/turbo/issues/5332
RUN npm update

RUN npm install

Since we are running update on the package.json and package-lock.json that turbo pruned and spat out, we think it should be fine, but needs more testing.

A few caveats:

varl commented 1 year ago

I added this line to my Dockerfile before running npm install, and looks like the npm version in node:18-alpine is just plain old (8.19.3).

COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json

RUN npm install --global npm@9.8.1

RUN npm install

With a newer npm version it works great. Hope this helps.

anthonyshew commented 11 months ago

Based on the comments above, it sounds like this is an npm issue rather than an issue with --prune.

I'll close this out but please open a fresh issue if you're still running into this problem.