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

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

Related

Sanity Studio: Parsing Error for Babel Preset Env

I'm new to working with Sanity, and just set up a project. Everything is working fine, however, in Visual Studio Code, I keep getting a parsing error that won't disappear, and I'm wondering how I can fix it.
Parsing error: Cannot find module '#babel/preset-env'
I've tried deleting the node_modules and re-running sanity install, I've also tried using npm install to install #babel/core and #babel/preset-env. Nothing seems to have fixed the problem so far.
Any suggestions? I want to start using Sanity with my team at work, but having this error is really quite annoying (as everything is underlined in red).
I was having a similar issue. For me, the issue was related to the way VS Code deals with a project containing multiple ESLint working directories (common in monorepos).
For example
Project
|--- /web
|--- /studio
In my project root, edit (or create) ./.vscode/settings.json to include my ESLint projects. NB: these settings only apply to your current workspace.
"eslint.workingDirectories": ["./web", "./studio"]
Hope that helps :-)
Method 1:
Create a file called .babelrc in your root directory and add this code
{
"presets": ["next/babel"],
"plugins": []
}
And in .eslintrc replace the existing code with
{
"extends": ["next/babel"]
}
Method 2:
You need to install npm with this command:
npm install --save-dev #babel/core #babel/preset-env
or
npm install --save-dev #babel/core
I hope this will solve your problem.

Next.js: Module not found: Can't resolve 'canvg'

I have a next.js project and I keep getting:
error - ./node_modules/jspdf/dist/jspdf.es.min.js:458:25
Module not found: Can't resolve 'canvg'
I'm not sure why because I'm not including either jspdf or canvg.
Not sure what's causing it. Any help would be appreciated. I'm using material-ui if that matters.
It seems dependency error means that particular Module is missing when it's running.
Run npm ls or yarn list will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure. Then search for that particulate packages are listed or not.
Run npm ls jspdf or yarn list jspdf then you can see its list of dependencies in tree-structure.
Please check your node version is updated or not ? If not then update first.
Quick & Dirty way: delete package.lock or yarn.lock file and delete .node_modules folders And Then run npm install or yarn to install again.
Look at console while you installing and make sure there are no error in the installing process. If you saw error you better look that massages also.

parcel-plugin-transcrypt fails with 'Error: Cannot find module 'parcel-bundler/src/Logger'

In a web project using yarn as package manager and parcel as bundler, I want to let Parcel transpile Transcrypt (Python) files to Javascript.
For this I installed parcel-plugin-transcrypt. But now when I bundle the project via parcel serve I get the following error:
Cannot find module 'parcel-bundler/src/Logger
Googling shows that this seems to be some version issue other plugins have encountered too. However I could not find a solution for parcel-plugin-transcrypt.
Any way to fix this?
The plugin for Transcrypt references files that have been refactored in newer versions of the bundler. To get it to work you need to add three missing files required by the build process. It's a work around for an underlying issue, but it fixes the problem for now. I use 3 wget commands to pull the files out of github and put them into the appropriate node_modules folder. So after installing parcel-bundler with npm, from the root folder of the project I run these:
wget -P ./node_modules/parcel-bundler/src/ https://raw.githubusercontent.com/parcel-bundler/parcel/b1e6d59cc44489f20013fa3171e09788978d7aed/packages/core/parcel-bundler/src/Logger.js
wget -P ./node_modules/parcel-bundler/src/utils/ https://raw.githubusercontent.com/parcel-bundler/parcel/b1e6d59cc44489f20013fa3171e09788978d7aed/packages/core/parcel-bundler/src/utils/prettyError.js
wget -P ./node_modules/parcel-bundler/src/utils/ https://raw.githubusercontent.com/parcel-bundler/parcel/b1e6d59cc44489f20013fa3171e09788978d7aed/packages/core/parcel-bundler/src/utils/emoji.js

Webpack can't import package installed from git

So I forked a package in the git. Made my changes. Then in my terminal
npm install --save git+https://github.com/hayk94/ddp.js.git
And then I try to import the package in my code as this
import DDP from 'ddp.js'
But webpack gives me this error
ERROR in ./main.js
Module not found: Error: Can't resolve 'ddp.js' in '/Users/hayksafaryan/projects/b2cEmbedLib'
# ./main.js 23:11-28
# multi (webpack)-dev-server/client?http://localhost:8080 babel-polyfill ./main.js
webpack: Failed to compile.
However webpack works fine if I install the package from npm.
I import the package as in the docs, however maybe there is some other way for git installed packages?
The entry point of the package is lib/ddp.js, but that file doesn't exist in the repository. It is very common that libraries build their libraries before publishing to npm, so that they can use newer JavaScript features but still provide support for older versions that don't support them. This is done with the prepublish hook, which is automatically run before the package is published (when you run npm publish). With that, the built files don't end up in the repository, as it would mainly clutter up your commits. Some people decide to check them in so they can use it directly from there, which has become quite rare because these use-cases are generally covered by services like Unpkg.
You have several possibilities to use it from a git repository.
Check in the built files.
Build the files after installing. Either manually or with a postinstall hook. (not recommended)
Change the entry point to src/ddp.js. If you need to transpile the files, this isn't a valid option, even though you could theoretically whitelist the package in your webpack config, so it gets transpiled (assuming you were excluding node_modules from being transpiled).
Publish the package to npm under your namespace (#yourusername/ddp.js) and use that. For details see Working with scoped packages.

how to use yarn to install swal

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.

Categories

Resources