how to use yarn to install swal - javascript

I'm new to yarn.
So I've my rails 5.1 application with yarn, I want to add this package:
https://yarnpkg.com/en/package/swal
So I do:
yarn add swal
it got added to node-modules/swal a lot of files but not the js that I should require.
I go to that folder and do npm install.
but I still dont have my swal.js to include...
I read the README and it says to run npm run build, it throws a dependency with vue error.
So I start to wonder.. I 've to investigate how to build each JS? Is that better than just get the .js already compiled and put it on vendor folder?
Anyway my question here is concrete, what is the way to add swal.

Related

r.js with old build system (bower) error with bootstrap

I am trying to move away from bower (since Reactjs is discontinued for it, maybe also other components)
Used bower-away to make package.json
Seem to went further, however bootstrap.js while ”traced” or how it is called by r.js produces error
Command run
r.js -o $(BUILD_TMP_DIR)/static/js/build.js
r.js error: line 778 unexpected token
However this is just normal bootstrap.js file
npm install bootstrap --save
I looked also at the bootstrap.js and it looks like a normal JS file
Is there a way to fix it? Maybe not even use r.js to produce build.js?
what are my options?
Update 1
I am new to Frontend, this also seems like older/legacy code.
Yes, project I think uses requirejs
https://github.com/marcinguy/betterscan-ce/blob/master/quantifiedcode/frontend/src/js/config.js
The code is open source I try to fix:
https://github.com/marcinguy/betterscan-ce/tree/master/quantifiedcode/frontend
You need to just run make to build it
https://github.com/marcinguy/betterscan-ce/blob/master/quantifiedcode/frontend/Makefile
I modified it with bower-away to use only package.json. Changed Makefile and src/js/config.js to work with node_modules instead of bower_components
r.js worked for reactjs and prism, but errors on bootstrap
installed
npm install reactjs --save
npm install prism --save
etc
Here is bower.json
https://github.com/marcinguy/betterscan-ce/blob/master/quantifiedcode/frontend/bower.json
Maybe I should try different npm install bootstrap? but which?
I have node 14

Getting Node Module Error (Cannot find module)

I am learning the Automated tests by using selenium web driver + Javascript and node.js.
Everything is working fine when I ran that script.js from the Visual Studio code terminal(by using node main.js)
Problem
I want to schedule this script in the scheduler which automatically tests the login functionality. But when I try to run it from the task scheduler then it gives Error: Cannot find module
Does anybody know how to get rid of this.
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's app. ... or delete the node_modules folder and package-lock. json file and re-install it again using the npm install command.
rm -rf node_modules package-lock.json

Unexpected end of JSON input while parsing react

After I use npm install I get this error in this link below
https://imgur.com/wavzFGd
I have this problem today and i don't know why
These kind of problems could be happening when clashing react modules.
Delete node_module folder and package-lock.json file. Then run again npm install.

how do i run jest test on a node_modules folder in react

I have added my own another project as a dependency. now it's on the node_modules folder now
how do I run test file on that folder when running the npm test
I don't know what your needs are but this is wrong.
If you want your project to be a dependency there are other safest ways to do that.
For example, with yarn, you can install a package from your computer as a dependency.
Consider the following example: you have your main-project, in which you want to include your sub-project.
So, in your main-project directory you can run yarn add ../path/to/sub-project and yarn will copy the code of your sub-project into the main-project. In this way you can keep the code splitted in two different reporitories.
A better way, if your sub-project is on github, bitbucket or whatever, is to give to yarn the url of your repo.
Yarn will automatically clone the repo into your node_modules every time that you'll run yarn. You can also specify a specific commit to use.
Read more about that in the yarn documentation.

how to use jsdoc in local project

Goal
I want to use jsdocs with npm.
Background
I am new to npm and its plugins. Recently I found out about jsdoc and I tried using it, with no success.
What I tried
First I installed the package using npm's command npm install --save jsdoc, and the install completed successfully.
However, when I try to use it in my project (I am inside the project's folder) I type jsdoc example.js and I get the following error:
/home/ubuntu/.nvm/versions/node/v4.4.5/bin/jsdoc: No such file or
directory
This leads me to think that:
I am in the wrong directory. If so, where should I be? (other than the project root folder)
The installation had a problem, even though it was successfull.
I have also tried to run npm jsdoc example.js but I get another error (this time from npm, saying I am not using it correctly).
I also installed jsdoc globally (using the -g flag) and it worked, but I truly want to avoid this because not all projects are using jsdoc.
Summary
To conclude, I am looking for a way to run jsdoc locally to a project with npm. Does anyone know of a way to do this?
To run jsdoc in the command line, the location of the jsdoc needs to be known. So when you have installed jsdoc globally, system would be able to find the file.
However if you want to run it locally, you need to include the file location before the jsdoc command.
For example, try using ./node_modules/jsdoc/jsdoc.js example.js

Categories

Resources