Search Unity

How can I fetch packages from @organization scope from npmjs

Discussion in 'Package Manager' started by RoaBen, Feb 12, 2021.

  1. RoaBen

    RoaBen

    Joined:
    Feb 13, 2019
    Posts:
    5
    Hello everyone, I've enjoyed working with custom packages in upm so far! :D

    Our @organization scoped package is @goodpatch/com.goodpatch.packagename on https://registry.npmjs.org/, but I cannot seem to make it work with upm.

    I logged in into npm using both
    npm login --registry=https://registry.npmjs.org/

    and
    npm login --registry=https://registry.npmjs.org/ --scope=@goodpatch


    My .npmrc is
    Code (JavaScript):
    1. @goodpatch:registry=https://registry.npmjs.org/
    2. //registry.npmjs.org/:_authToken=<token>
    The contents of the .upmconfig.toml located at %USERPROFILE%\ is:

    Code (JavaScript):
    1. [npmAuth."https://registry.npmjs.org"]
    2.  
    3. token = "<token>"
    4.  
    5. email = "<email>"
    6.  
    7. alwaysAuth = true
    and the contents of my manifest.json in Packages/ is:

    Code (JavaScript):
    1. {
    2.   "dependencies": {
    3.     "com.goodpatch.packagename": "1.2.1"
    4.   },
    5.   "scopedRegistries": [
    6.     {
    7.       "name": "npmjs",
    8.       "url": "https://registry.npmjs.org/",
    9.       "scopes": [
    10.         "@goodpatch/com.goodpatch"
    11.       ]
    12.     }
    13.   ]
    14. }
    15.  
    Based on a lot of research I did in this forum I already tried:

    My package is configured like this:

    Code (JavaScript):
    1.  {
    2. "name": "@goodpatch/com.goodpatch.packagename",
    3.   "version": "1.2.1",
    4.   ...
    5. }
    On npmjs.com:


    I get this error:

    Using Unity 2020.1.15f1


    I can get it just fine using npm install @goodpatch/com.goodpatch.packagename . Does anyone have an idea on how to get our @goodpatch/com.goodpatch.packagename from https://registry.npmjs.org/ using unity package manager? Thank you!
     
    Last edited: Feb 16, 2021
    xinatcg likes this.
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,065
    As mentioned in the documentation:
    As far as I know, Unity doesn't plan to add support for @-scope. As such, using private npm packages is not possible.
     
  3. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    It's not possible.

    Some registries like GitHub didn't verify the package name strictly, so you can use the trick that https://domain.com/some-path/@org-name as the registry URL, and put the package name without @org-name in the package.json.

    But NPMJS requires you to put @org-name in the package.json as part of the package name. Unity doesn't like that.