Auth0 Home Blog Docs

Adding auth0.js to my build system

lock
auth0js

#1

Hi,

I’m new to Auth0, Lock, and web development tools. I am current working on a simple web and I want to implement the login using Auth0 Lock and Javascript. I started working through the “JavaScript: Login” tutorial on the Auth0 website and I was able to install auth0.js using nom through the Terminal App on Mac… the following is where I am stuck:

Once you install auth0.js, add it to your build system or bring it in to your project with a script tag.

Where do I type in this command? It doesn’t seem to working in Terminal… Any help on this issue would be greatly appreciated.

Thanks!
mkhan


#3

:wave: @mkhan you can install auth0.js using npm at the root level of your application. This will bring the library into your project at node_modules/auth0-js/build/auth0.js and so we can add <script type="text/javascript" src="node_modules/auth0-js/build/auth0.js"></script> to our .html file for exampe.

If you download the sample project, all you need to do is run npm install from the root folder (that being 01-login) and you’ll see node_modules folder appear. Within node_modules is many packages, one of those being auth0js. We need this library to be able to use Auth0 in our application.

The reason for running these commands is you’ll also notice a package.json.lock file appear. Without going into too much detail this handles all our dependencies. Our projects might have hundreds of dependencies (external code written by you or someone else), each of those with a hundred others…

npm handles the complexity of dependencies and packages that our application needs to fun without us having to think twice. That is why when we say If you do not want to use a package manager, if you do not want to use npm or yan, package/dependency managers, instead of the above steps you can instead retrieve auth0.js from Auth0’s CDN. This is an alternate approach.

It doesn’t seem to working in Terminal

What is happening when you run the command in the terminal?


#4