2
I installed the Knockout.js library via NPM, by the following command:
npm install --save-dev knockout
I noticed that NPM installs the module inside the node_modules/knockout folder, but I believe there is a way to include the script in the project without having to refer it to the following path in my index.html:
<script src="node_modules/knockout/build/output/knockout-lastest.js></script>
How do I include it in the right way?
Where are you wearing the
Knockout
? you have some compiler like webpack, Browserify?– Sergio
not @Sergio. I just installed via NPM. I must install the webpack and call the package there?
– Aline Vianna
In that case, it seems more like "old-fashioned" NDC. If you want to hide possible global variables from Knockout.js you can use one of these compilers/packers or require.js. But you’ll be adding complexity that can only get in the way...
– Sergio
I got it.. I wanted to use via NPM just to try it out. But I agree with you that maybe it doesn’t pay to leave complex something that can be simpler. Thanks for your help, @Sergio
– Aline Vianna
You’re welcome. Yeah, it’s always good to try it. And you can use it locally by going to
node_modules
. Where is your HTML file compared tonode_modules
? You have a server or are testing locally?– Sergio
I’m using it locally. The index is inside the "source" folder. Going back one level, comes the node_modules folder at the project root. My goal is to create a folder with project editing files, and another publication folder, called "dist", where I will include, after running Grunt, all the files from the minified and concatenated source folder.
– Aline Vianna
To use Knockout.js via
node_modules
can do<script src="../node_modules/knockout/build/output/knockout-lastest.js></script>
if I have understood the structure of the directories well. You could have Grunt fetch that file fromnode_modules
and use fromdist
also... several options :)– Sergio
Beauty @Sergio! Thank you so much ;)
– Aline Vianna