'unable to publish my npm package got this error 415 Unsupported Media Type - No package.json found in tarball?
when I run npm publish it shows 415 Unsupported Media Type - PUT https://registry.npmjs.org/json-to-plain-text - No package.json found in tarball
i dont know why it is showing like this,Is there any problem with my pc. I'm using parrot OS with nodejs version v12.22.5 and npm version 7.5.2
~$ cat /home/sumith/.npm/_logs/2022-03-21T16_14_00_789Z-debug.log
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'publish' ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/share/nodejs/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:/home/sumith/repos/json-to-plain-text/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/home/sumith/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 7ms
19 verbose npm-session 7f303ef810561d7f
20 timing npm:load Completed in 14ms
21 verbose publish [ '.' ]
22 notice
23 notice 📦 [email protected]
24 notice === Tarball Contents ===
25 notice 11B /.gitattributes
25 notice 4B /.prettierignore
25 notice 96B /.prettierrc.json
25 notice 3.7kB /index.js
25 notice 7B /json-to-plain-text.version
25 notice 1.5kB /lib/helper.js
25 notice 4.3kB /lib/lib.js
25 notice 1.1kB /LICENSE
25 notice 638B /package.json
25 notice 3.4kB /README.md
25 notice 988B /test/test.js
26 notice === Tarball Details ===
27 notice name: json-to-plain-text
27 notice version: 1.0.3
27 notice filename: json-to-plain-text-1.0.3.tgz
27 notice package size: 4.1 kB
27 notice unpacked size: 15.8 kB
27 notice shasum: 886d5f0bfcdf85d3755e3dcfc4c7efab1168b9be
27 notice integrity: sha512-fMvvgpV7nQ1pn[...]Cl4fiZJJbe1rg==
27 notice total files: 11
28 notice
29 http fetch PUT 415 https://registry.npmjs.org/json-to-plain-text 1839ms
30 timing command:publish Completed in 1905ms
31 verbose stack Error: 415 Unsupported Media Type - PUT https://registry.npmjs.org/json-to-plain-text - No package.json found in tarball
31 verbose stack at /usr/share/nodejs/npm/node_modules/npm-registry-fetch/check-response.js:123:15
31 verbose stack at async publish (/usr/share/nodejs/npm/node_modules/libnpmpublish/publish.js:43:12)
31 verbose stack at async publish_ (/usr/share/nodejs/npm/lib/publish.js:120:5)
31 verbose stack at async publish (/usr/share/nodejs/npm/lib/publish.js:43:19)
32 verbose statusCode 415
33 verbose pkgid [email protected]
34 verbose cwd /home/sumith/repos/json-to-plain-text
35 verbose Linux 5.16.0-12parrot1-amd64
36 verbose argv "/usr/bin/node" "/usr/bin/npm" "publish"
37 verbose node v12.22.5
38 verbose npm v7.5.2
39 error code E415
40 error 415 Unsupported Media Type - PUT https://registry.npmjs.org/json-to-plain-text - No package.json found in tarball
41 verbose exit 1
Solution 1:[1]
Having the same problem. This is my speculation, but I suspect that this is a problem on NPM registry's server side. 'package.json' is clearly being compressed, as can be seen in the 'Tarball Contents' section. The npm cli made a request to the NPM server (registry.npmjs.org), but for some reason, the code on the npm registry is rejecting the tarball and either diagnosing a problem where there is none or telling us that there's a problem but misdiagnosing. But to be extra sure, maybe try 'npm pack' first, then use 'tar -tzvf json-to-plain-text-1.0.3.tgz' to check the tarball contents, and then 'npm publish json-to-plain-text-1.0.3.tgz'?
Nvm. I know the answer now. Turns out that nodejs 12 is kind of outdated. Try using nodejs v17 using this method. I personally think the Debian repos are at fault for being so behind.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
