Giter VIP home page Giter VIP logo

Comments (8)

simllll avatar simllll commented on July 21, 2024 1

Nice finding of @pkerschbaum https://docs.npmjs.com/cli/v9/using-npm/scripts#npm-rebuild

npm` rebuild
preinstall
install
postinstall
prepare
prepare is only run if the current directory is a symlink (e.g. with linked packages)

which exactly explains our issue, because we have a symlink there (in the nature of pnpm)

from uuid.

broofa avatar broofa commented on July 21, 2024

Closing for the time being, as I'm not able to reproduce the issue (see below). npm rebuild, yarn rebuild, and pnpm rebuild all run without issue for me. So I'm suspicious this is something specific to your environment. But feel free to put up a test case that allows us to reproduce the problem and I'll reopen.

That said... there does seem to be something to this. I think you / we are falling afoul of some combination of poor documentation and deprecated behavior in npm. The npm build command used to be a thing, but support and documentation for it was quietly dropped after npm@6. Yet npm rebuild is spec'ed as "runs the npm build command" is still a thing. I've opened this discussion to see what the npm folks have to say.

Regardless, where this project is concerned I don't think we're relying on the built-in interpretation of build. Our versionwent in 3 years ago and is only used for generating the products we bundle when publishing the package. (Which means renaming this to postinstall would not be appropriate, btw.)


$ pwd
/tmp

$ mkdir foo

$ cd foo

$ npm init -y
Wrote to /private/tmp/foo/package.json:

<...snip>

$ npm install uuid

added 1 package, and audited 2 packages in 394ms

found 0 vulnerabilities

$ npx pnpm --version
7.27.1

$ npx pnpm rebuild

$

$ npm rebuild 
rebuilt dependencies successfully

$

$ npm rebuild --ignore-scripts
rebuilt dependencies successfully

$

from uuid.

simllll avatar simllll commented on July 21, 2024

are you sure it's about the build script and not about the prepare script?

The weird thing I thought is the reason is that sometimes it seems the prepare script is even run on install. See https://docs.npmjs.com/cli/v9/using-npm/scripts

NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.

It seems somehow it assumes that it is a git package in my environment I guess? Or what do they try us to say with this note?

The commands i run:
$ pnpm i
$ pnpm deploy --prod --filter package ./output
Copy the whole Output inside a docker alpine image (it contains the node_modules folder)
Run npm rebuild inside docker.

Maybe it's caused by another dependency that uses UUID, i will look into that tomorrow.

Regarding prepare and postinstall I have to agree though, I'm not sure what brought me to this suggestion 🙈

from uuid.

broofa avatar broofa commented on July 21, 2024

I think that NOTE only applies when pulling a module directly from a git repo. E.g. if you had the uuid dependency in package.json declared as "uuid": "git+https://github.com/uuidjs/uuid.git".... which I assume isn't the case here.

from uuid.

simllll avatar simllll commented on July 21, 2024

One small update:
we have issues with other prepare steps too, so somehow npm thinks it needs to run the prepare hooks in our setup. Ppbl a npm bug though, will let you know if we create a bug report over at npm for it.

from uuid.

broofa avatar broofa commented on July 21, 2024

Interesting. I guess the assumption there is that symlinks reference local / unpublished modules. E.g. as you'd get with npm link or yarn workspaces.

Note: In my test, above I used npm to install uuid, which doesn't create a symlink. But even if I use pnpm for the install (and, thus, create a symlink) pnpm rebuild still works for me:

$ npx pnpm init
...

$ npx pnpm install uuid
...

$ ls -lF node_modules/uuid
lrwxr-xr-x  1 kieffer  wheel  34 Mar 20 09:25 node_modules/uuid@ -> .pnpm/[email protected]/node_modules/uuid

$ npx pnpm rebuild

$

from uuid.

simllll avatar simllll commented on July 21, 2024

Try to run npm rebuild instead.

pnpm rebuild without arguments is not working in our tests, it doesn't rebuild all packages / does nothing at all, it looks like it needs a positional argument to specify packages to rebuild, but haven't looked closer and it yet.

from uuid.

pkerschbaum avatar pkerschbaum commented on July 21, 2024

regarding pnpm rebuild I created this issue: pnpm/pnpm#6268

from uuid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.