npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.46k stars 3.15k forks source link

[BUG] Publish: 415 - Hard link is not allowed #3835

Closed DaXcess closed 2 years ago

DaXcess commented 3 years ago

Is there an existing issue for this?

Current Behavior

When trying to npm publish a node module, the registry returns a 415 - Hard link is not allowed

Expected Behavior

The module is published correctly

Steps To Reproduce

Dependencies: axios DevDependencies: @types/node, nan, typescript

The files that should be uploaded contain: A built Node-GYP module (so Makefiles and .node files), package.json (no package-lock.json), README.md

Publish log:

❯ npm --verbose publish
npm verb cli [ '/usr/bin/node', '/usr/bin/npm', '--verbose', 'publish' ]
npm info using npm@7.24.1
npm info using node@v16.10.0
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 0ms
npm timing config:load:builtin Completed in 0ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/home/rodabafilms/Projects/VorbisDecoder/.npmrc Completed in 0ms
npm timing config:load:project Completed in 1ms
npm timing config:load:file:/home/rodabafilms/.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/usr/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 0ms
npm timing config:load Completed in 6ms
npm timing npm:load:configload Completed in 6ms
npm timing npm:load:setTitle Completed in 0ms
npm timing npm:load:setupLog Completed in 0ms
npm timing config:load:flatten Completed in 1ms
npm timing npm:load:cleanupLog Completed in 1ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load:projectScope Completed in 1ms
npm timing npm:load Completed in 12ms
npm verb publish [ '.' ]
npm notice 
npm notice 📦  vorbisdecoder@1.0.0
npm notice === Tarball Contents === 
npm notice 28B    README.md                                                        
npm notice 118B   build/binding.Makefile                                           
npm notice 12.9kB build/Makefile                                                   
npm notice 242B   build/Release/.deps/Release/obj.target/vorbis-dec.node.d         
npm notice 5.0kB  build/Release/.deps/Release/obj.target/vorbis-dec/src/binding.o.d
npm notice 223B   build/Release/.deps/Release/vorbis-dec.node.d                    
npm notice 28.8kB build/Release/obj.target/vorbis-dec.node                         
npm notice 21.1kB build/Release/obj.target/vorbis-dec/src/binding.o                
npm notice 0B     build/Release/vorbis-dec.node                                    
npm notice 4.3kB  build/vorbis-dec.target.mk                                       
npm notice 368B   package.json                                                     
npm notice === Tarball Details === 
npm notice name:          vorbisdecoder                           
npm notice version:       1.0.0                                   
npm notice filename:      vorbisdecoder-1.0.0.tgz                 
npm notice package size:  19.6 kB                                 
npm notice unpacked size: 73.1 kB                                 
npm notice shasum:        6820f00464eb7a113ce73dc678e6d21134568651
npm notice integrity:     sha512-tN8QuEGvwLJVi[...]WiYfxBvSLV73w==
npm notice total files:   11                                      
npm notice 
npm timing command:publish Completed in 467ms
npm verb stack HttpErrorGeneral: 415 Unsupported Media Type - PUT https://registry.npmjs.org/vorbisdecoder - Hard link is not allowed
npm verb stack     at /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:95:15
npm verb stack     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm verb stack     at async publish (/usr/lib/node_modules/npm/node_modules/libnpmpublish/publish.js:43:12)
npm verb stack     at async Publish.publish (/usr/lib/node_modules/npm/lib/publish.js:120:7)
npm verb statusCode 415
npm verb pkgid vorbisdecoder@1.0.0
npm verb cwd /home/rodabafilms/Projects/VorbisDecoder
npm verb Linux 5.14.7-2-MANJARO
npm verb argv "/usr/bin/node" "/usr/bin/npm" "--verbose" "publish"
npm verb node v16.10.0
npm verb npm  v7.24.1
npm ERR! code E415
npm ERR! 415 Unsupported Media Type - PUT https://registry.npmjs.org/vorbisdecoder - Hard link is not allowed
npm verb exit 1
npm timing npm Completed in 562ms
npm verb code 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rodabafilms/.npm/_logs/2021-10-05T09_52_29_696Z-debug.log

NPM 6 does not appear to be having this problem

Environment

DaXcess commented 3 years ago

Pardon me I accidentally pressed enter before finishing the issue template

LaurensRietveld commented 3 years ago

I have the same issue, also with publishing a package that uses node-gyp.

Edit: I foud the hard links. In my case, they were caused by prebuildify. I implemented a workaround to copy the files instead, but hope there is a more robust solution than that in the future

wraithgar commented 2 years ago

The npm registry does not support hard links, and any build step that introduces them is not going to work for a package you want to publish. This is a bug to be worked out with the package itself that is building hard links. There is not much the npm cli can do about this, it's running the code that it was asked to run.

You may need to tell npm to ignore those linked build assets, as they are likely not intended to be part of the published module.