Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm dist add not working #21

Closed
ghost opened this issue May 5, 2015 · 30 comments
Closed

npm dist add not working #21

ghost opened this issue May 5, 2015 · 30 comments

Comments

@ghost
Copy link

ghost commented May 5, 2015

this is my command i keep trying to run and it won't work. npm dist-tag add test@1.0.1 latest

here is the log:

0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'dist-tag',
1 verbose cli 'add',
1 verbose cli 'test@1.0.1',
1 verbose cli 'latest' ]
2 info using npm@2.7.3
3 info using node@v0.12.0
4 verbose node symlink /usr/local/bin/node
5 verbose dist-tag add latest to test@1.0.1
6 silly mapToRegistry name test
7 silly mapToRegistry using default registry
8 silly mapToRegistry registry http://localhost:15443/
9 silly mapToRegistry uri http://localhost:15443/test
10 verbose request uri http://localhost:15443/-/package/test/dist-tags
11 verbose request no auth needed
12 info attempt registry request try #1 at 11:53:24
13 verbose request id 62b5673de17b3467
14 http request GET http://localhost:15443/-/package/test/dist-tags
15 http 404 http://localhost:15443/-/package/test/dist-tags
16 verbose headers { 'content-type': 'application/json',
16 verbose headers date: 'Tue, 05 May 2015 16:53:24 GMT',
16 verbose headers connection: 'keep-alive',
16 verbose headers 'transfer-encoding': 'chunked' }
17 verbose stack Error: missing : -/package/test/dist-tags
17 verbose stack at CachingRegistryClient. (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:254:14)
17 verbose stack at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:178:14)
17 verbose stack at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:344:22)
17 verbose stack at Request.emit (events.js:110:17)
17 verbose stack at Request. (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1239:14)
17 verbose stack at Request.emit (events.js:129:20)
17 verbose stack at IncomingMessage. (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1187:12)
17 verbose stack at IncomingMessage.emit (events.js:129:20)
17 verbose stack at _stream_readable.js:908:16
17 verbose stack at process._tickCallback (node.js:355:11)
18 verbose statusCode 404
19 verbose cwd /Applications/NODEJS/howtonpm
20 error Darwin 14.3.0
21 error argv "node" "/usr/local/bin/npm" "dist-tag" "add" "test@1.0.1" "latest"
22 error node v0.12.0
23 error npm v2.7.3
24 error code E404
25 error 404 missing : -/package/test/dist-tags
26 verbose exit [ 1, true ]

@coloradude
Copy link

I'm having issues with this one as well.

@buck-yeh
Copy link

Same here too!

@denmch
Copy link

denmch commented May 30, 2015

This actually does work. See this note on FreeCodeCamp's implementation of how-to-npm for details about the bug and how to avoid it: freeCodeCamp/freeCodeCamp#758

@buck-yeh
Copy link

I just figured it out. Should have typed
npm dist-tag add @buck/pkg@1.0.1 tttt
Instead, I typed
npm dist-tag add pkg@1.0.1 tttt

@gautammadaan
Copy link

@buck-yeh can you elaborate what was "buck" and "pkg" in your case? I am facing the same issue.

@denmch
Copy link

denmch commented Jun 5, 2015

@gautammadaan I spent some more time with this and narrowed it down. The real issue for most users experiencing problems with this portion of the tutorial is a misunderstanding of how versions are created and published and how dist-tags relate to them.

If you make a mistake, e.g., trying to apply a dist-tag to a version number that hasn't been published, the app throws up errors and ceases to work as expected. The solution is to run how-to-npm again and, if necessary, repeat the previous step (or steps).

In other words, you may need to go back two steps to use npm version patch (or similar) and note the version number. Then publish that version. Then use the correct syntax to add a dist-tag to the newly published version.

If you follow those steps the tutorial works perfectly. But it will continue to throw errors and fail to add dist-tags if you make a mistake or if you attempt to do certain actions on steps other than those on which they are being tested.

@gautammadaan
Copy link

@denmch Thanks a lot of that. Yes you are right! The part of the tutorial that didn't work for me was "npm publish" and so it was throwing up errors later on in the tutorial.

@denmch
Copy link

denmch commented Jun 5, 2015

I still consider this a bug, because npm dist-tag ls lists the erroneous dist tags even though they were invalid. And once you make this mistake, the dist-tag portion of the tutorial becomes unusable and how-to-npm must be restarted.

It looks to me that something is broken around the error messages, I see these errors related to dist tags in registry.js but they don't seem to come up when you commit the errors:

126:
return _403(req, res, { error: 'invalid version' })

137–9:
return _403(req, res, { error: 'You may not have a dist tag that is also a valid version' })

143–145:
return _403(req, res, { error: 'Tag points at invalid version: ' + dt + ' -> ' + ver })

@ghost
Copy link
Author

ghost commented Jun 5, 2015

I agree. I consider this about alsoJosh CSent from Yahoo Mail for iPhoneAt Jun 5, 2015, 5:06:12 PM, Den McHenry wrote:I still consider this a bug, because npm dist-tag ls lists the erroneous dist tags even though they were invalid. And once you make this mistake, the dist-tag portion of the tutorial becomes unusable and how-to-npm must be restarted.

It looks to me that something is broken around the error messages, I see these errors related to dist tags in registry.js but they don't seem to come up when you commit the errors:

126:
return _403(req, res, { error: 'invalid version' })

137–9:
return _403(req, res, {
error: 'You may not have a dist tag that is also a valid version'
})

143–145:
return _403(req, res, {
error: 'Tag points at invalid version: ' + dt + ' -> ' + ver
})

—Reply to this email directly or view it on GitHub.

@leepowelldev
Copy link

+1
This part of the tutorial is very confusing and doesn't do much to help explain how to use dist-tag effectively. I'm sure others have got it to work, but I couldn't.

@jfmaggie
Copy link

I am having the same problem here. Tried repeat last two steps and avoid any irrelevant command, still no luck.

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/Users/Maggie/npm-global/bin/npm', 'dist-tag', 'ls' ]
2 info using npm@2.13.0
3 info using node@v0.12.0
4 silly mapToRegistry name xiaojingling
5 silly mapToRegistry using default registry
6 silly mapToRegistry registry http://localhost:15443/
7 silly mapToRegistry uri http://localhost:15443/xiaojingling
8 verbose request uri http://localhost:15443/-/package/xiaojingling/dist-tags
9 verbose request always-auth set; sending authorization
10 info attempt registry request try #1 at 3:37:28 PM
11 verbose request id 8e9018f190ad3d49
12 http request GET http://localhost:15443/-/package/xiaojingling/dist-tags
13 http 404 http://localhost:15443/-/package/xiaojingling/dist-tags
14 verbose headers { 'content-type': 'application/json',
14 verbose headers   date: 'Sat, 11 Jul 2015 22:37:28 GMT',
14 verbose headers   connection: 'keep-alive',
14 verbose headers   'transfer-encoding': 'chunked' }
15 error dist-tag ls Couldn't get dist-tag data for xiaojingling
16 verbose stack Error: missing : -/package/xiaojingling/dist-tags
16 verbose stack     at CachingRegistryClient.<anonymous> (/Users/Maggie/npm-global/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:247:14)
16 verbose stack     at Request._callback (/Users/Maggie/npm-global/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:170:14)
16 verbose stack     at Request.self.callback (/Users/Maggie/npm-global/lib/node_modules/npm/node_modules/request/request.js:197:22)
16 verbose stack     at Request.emit (events.js:110:17)
16 verbose stack     at Request.<anonymous> (/Users/Maggie/npm-global/lib/node_modules/npm/node_modules/request/request.js:1050:14)
16 verbose stack     at Request.emit (events.js:129:20)
16 verbose stack     at IncomingMessage.<anonymous> (/Users/Maggie/npm-global/lib/node_modules/npm/node_modules/request/request.js:996:12)
16 verbose stack     at IncomingMessage.emit (events.js:129:20)
16 verbose stack     at _stream_readable.js:908:16
16 verbose stack     at process._tickCallback (node.js:355:11)
17 verbose statusCode 404
18 verbose cwd /Users/Maggie/howtonpm-workshop
19 error Darwin 14.3.0
20 error argv "node" "/Users/Maggie/npm-global/bin/npm" "dist-tag" "ls"
21 error node v0.12.0
22 error npm  v2.13.0
23 error code E404
24 error 404 missing : -/package/xiaojingling/dist-tags
25 verbose exit [ 1, true ]

@mpmckenna8
Copy link

I was getting the same 404 error and couldn't figure out what was wrong because if typed as above it will work for regular modules but not in our how-to-npm dev environment.

To finally get it to work I used:
npm dist-tag add @mpmckenna8/whonpm@0.0.3 what

Where the reference to the module starts with the @username/moduleName/version and in this case the dist-tag to add is what. Making this syntax explicit in the lesson text would probably be useful.

@iuvbio
Copy link

iuvbio commented Jul 25, 2015

same problem here. repeated the last two steps, I have three versions (1.0.0, 1.0.1, 1.0.2), all of them are definitely published. I have tried the syntax @mpmckenna8 proposed and the "normal" one without the username, but both didn't work.

404 missing : -/package/@iuvbio%2fhow-to-npm/dist-tags

@Silerra
Copy link

Silerra commented Jul 26, 2015

I recently had the same problem. I can't understand why the step "Dist Tag" fails when the "npm publish" had previously failed once. Then I have tried different ways to go about this bug out of the way.

Finally helped me only the following steps:

  1. Delete the project folder in which you last used for your workshop.
  2. Empty your trash folder. (Because Ubuntu derivatives possibly the 'HOW-TO-NPM' a dirty link created to the Trash. That already happened to me too.)
  3. Reset the Workshop with: how-to-npm reset
  4. Create again a new folder for your how-to-npm workshop.
  5. Start again your project. However possible tidy.

Good luck!

@iuvbio
Copy link

iuvbio commented Jul 27, 2015

@Silerra I've done this as well and I'm still getting the same error...

@tad
Copy link

tad commented Jul 31, 2015

I've run into the same problem as above.

Aborting this chapter due to stuff like this.

@DougRiblet
Copy link

After a dozen failures, I got it to work by restarting the exercise and using 'npm dist-tag add @smashzen/smashproject@1.0.0 newt' (following the mckenna formula above).

@aBuzzLife
Copy link

^^ This. After many a fail myself, I finally got this to work for me. Thank you smashzen. Good vibes

@claudiopro
Copy link
Member

@denmch @buck-yeh @mpmckenna8 thanks, using fully qualified module names did the trick!

@Deftwun
Copy link

Deftwun commented Sep 29, 2015

I couldn't get this to work either so I edited /.config/how-to-npm/registry/my_package_name/body.json and manually included my own tag in 'dist-tags' section. Then ran how-to-npm verify and it gave me a success message. I had to delete the tag and change the 'latest' version for the next challenge manually too. Not really a fix but at least it says completed now...

@ZebGirouard
Copy link

@denmch thank you. I really cannot stress enough the importance of this line:

"The solution is to run how-to-npm again and, if necessary, repeat the previous step (or steps)."

This is NOT MENTIONED in the tutorial. In particular, on Step 11 (Dist Tag Removal) it seems to be impossible to run npm publish, without getting errors thrown, yet it is necessary in order to get the tests to pass. It is not just a problem of tests not passing, the command simply WILL NOT RUN in Step 11, so you must go to one of the Publish steps, npm publish tag=something, then return to Step 11, and run how-to-npm verify. This sucked up almost 2 hours of my day. I hope this post helps other people understand the problem quicker.

If you are getting confusing errors, try to return to a step in the tutorial where the command worked, and run the command again.

P.S. @denmch , perhaps you can add a note to this effect in the instructions on the FreeCodeCamp waypoint for this? I appreciate the note about only applying tags to versions that have been published, but this error situation seems way more common and confusing.

@ashleygwilliams
Copy link
Contributor

closing for #45

@RandyDavis
Copy link

I was having pretty much all of the issues as everyone above and definitely was thinking that I was not doing something right and then I did the following and it worked:

  1. Enter "npm ls" command and hit enter to get the correct user and module names along with version number
  2. The first line it returns should be something like this @randy/workspace@1.0.1 /home/ubuntu/workspace
  3. Take the part from the beginning through the version number and enter the following command: npm dist-tag add @randy/workspace@1.0.1 test (test is the tag name)
  4. It should return +test: @randy/workspace@1.0.1
  5. Run how-to-npm verify command and it should pass

@msgesq
Copy link

msgesq commented Jun 16, 2016

Thanks @RandyDavis . Your solution worked for me and was the easiest to understand of the all the suggested solutions.

@ghost
Copy link

ghost commented Jun 25, 2016

Thank you @RandyDavis. I completely agree with mgrezzy. It's the best explanation. Pity that after 2hours strugling i found this explanation. THX

@tdbs
Copy link

tdbs commented Jul 14, 2016

It seems once you get into the 404 erros there's not a simple way back, i tried init the project again, doing ls to see the correct name of the project, nothing worked, an entry level tutorial should not be this fragile, and its ridiculous this is closed.

@ghost
Copy link
Author

ghost commented Oct 24, 2016

I had some problems with npm ls because it didn't list me out full name as @RandyDavis mentioned above. But there is solution for that.
Open your package.json file and look for name and version.
screenshot from 2016-10-24 15-48-04

Here you can see them on the beginning of package.json file.
And you write:
npm dist-tag add @dayfiri/dev_env@0.0.2 what

Where @dayfiri/dev_env is my name in package.json,
0.0.2 is version from package.json file also,
and what is [tag] name. Tag name is your choice what you wanna write.

@Mikestella
Copy link

@RandyDavis Thank you so much for explaining that even further. It has helped alot and I really appreciate it dude.

johndeyrup added a commit to johndeyrup/how-to-npm that referenced this issue Jan 15, 2017
 Numerous people were running into issues with the instructions for problem 11 - adding a dist tag see workshopper#21 I changed the wording of the instructions to show people how to figure out the package and version of a project.
johndeyrup added a commit to johndeyrup/how-to-npm that referenced this issue Jan 15, 2017
 Numerous people were running into issues with the instructions for problem 11 - adding a dist tag see workshopper#21 I changed the wording of the instructions to show people how to figure out the package and version of a project.

Fixed typos
@magdalenagorecka
Copy link

I had this same bug. What I did is:

  1. npm ls //to find out my root dir is: @gooretzka/char-example@2.0.3
  2. npm dist-tag add @gooretzka/chat-example@2.0.3 beta
    It worked.

@Rhpozzo
Copy link

Rhpozzo commented Apr 20, 2018

ronin:/workspace/fcc $ npm dist-tag add @ronin/fcc@1.2.4 beta
+beta: @ronin/fcc@1.2.4
ronin:
/workspace/fcc $ npm ls
@ronin/fcc@1.2.4 /home/ubuntu/workspace/fcc
└── @linclark/pkg@1.0.2

ronin:~/workspace/fcc $ how-to-npm verify

Congratulations!  You've added a dist-tag!

This is a handy way to manage releases.  For example, the npm project
itself publishes each new version as 'next' (instead of 'latest') so
that beta users can test it out before it becomes the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests