DEV Community

Discussion on: Create Your First Github Package

Collapse
 
davestewart profile image
Dave Stewart • Edited

Hey Dale,

Thanks so much for this tutorial! It's certainly got me the closest to publishing and installing a private package.

However, when I try this, my package – and your package – is installed unscoped.

It installs under node_modules/typescript-package-starter not node_modules/@dalenguyen/typescript-package-starter and you need to descope the require as well:

const starter = require('typescript-package-starter')
console.log(starter.helloWorld())

This is the same experience I have had with my own package.

When add the @org-name/ in the package.json name as per normal NPM packages...

{
  "name": "@dalenguyen/typescript-package-starter",
  ...
}

...the install command under GitHub packages ends up including the scope twice, so for your package would be:

npm install @dalenguyen/@dalenguyen/typescript-package-starter@1.0.0

I guess in theory the de-scoping I am experiencing should not be a problem – because the code works – but it's strange considering it could potentially clash with an unscoped package of the same name.

Any ideas?

P.S. You can color-code your codeblocks by appending the language name to codeblock backticks, i.e. '''js

Collapse
 
dalenguyen profile image
Dale Nguyen • Edited

Thank Dave for the question. I just tried my package. It installs under node_modules/@dalenguyen

Can you fork my project, modify and deploy to your Github package?

dev-to-uploads.s3.amazonaws.com/i/...

Collapse
 
davestewart profile image
Dave Stewart

Good plan. Let me try that

Thread Thread
 
dalenguyen profile image
Dale Nguyen

Let me know if it works. And can you help to remove the .npmrc file? The token is invalid, but it is better to remove it though. Thanks,