How to add braft-editor as a local dependency in my react app? - npm-package

I have cloned the repo of braft-editor. Done, "npm run build" and "npm install" on the clone of braft-editor. I have added braft-editor as the local dependency in my react app by putting "braft-editor": "file:../braft-editor" in the dependencies of package.json of react app. imported the BraftEditor package in App.js , but when render the BraftEditor component I get errors like, Uncaught Invariant Violation: block is not a BlockNode at invariant,at insertRawBlock.

Related

Yarn install a single package to single workspace

This is my project set up
proj:
package.json - workspaces["app/frontend", "app/backend"]
app
frontend - package.json
backend - package.json
say I cd to proj
I want to do yarn workspace app/frontend add uuid -dev (add a pkg to one of the workspace)
err is Unknown workspace "app/frontend", wonder what is the correct syntax?
yarn workspace frontend add uuid --save-dev
When you define your workspaces in the package.json you should use relative path to the workspace:
"workspaces": [
"app/frontent",
"app/backend"
]
However, when you refer to your workspace in yarn workspace ... command you should use the package name of this workspace (including namespace).
For example, if your frontend/package.json defines
{
name: "#myproj/frontend".
...
}
you will use
yarn workspace #myproj/frontent add uuid --save-dev

Yarn errors with Not Found for local Lerna packages

Calling yarn commands inside a package that references a local lerna package fails with
- packages
- package1
- package2
say package2 references package1
dependencies: [
"#my-scope/package1": "^1.0.0"]
When I run any yarn command in package2 e.g. yarn add, or yarn list I get an error:
An unexpected error occurred: "https://registry.yarnpkg.com/#myscope%2package1: Not found".
I have run lerna bootstrap at the top level with
"npmClient": "yarn"
which successfully builds all my packages and the node_modules of package2 contains package1, however the yarn.lock file does not have any of the local packages
What might I be doing wrong?
Your dependence version should match origin's version, otherwise, yarn will lookup by internet instead local package
Say
packages1's package.json:
{
"name": "#my-scope/package1",
"version": "0.0.1"
}
packages2's package.json:
{
"name": "#my-scope/package2",
"dependencies": {
"#my-scope/package1": "^1.0.0"
}
}
yarn can's find that version match ^1.0.0, so it just try fetch from yarnpkg.com

How to automatically add a module rule to react-scripts' webpack.config.js when using "npm install"

I've built my application with create-react-app, and to make it work I have to add
{
test: /node_modules.+js$/,
loader: require.resolve("ify-loader"),
},
to the module.rules array of react-scripts' webpack.config.js file.
What I should I do to make it add automatically when creating the node_modules folder with the command npm install?

How to use socket.io-client in electron?

I'm trying to add socket.io-client to my project.
I've installed
socket.io-client & #types/socket.io-client
but I'm getting this error when I try to build:
/myproject/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:37
TypeError: Cannot read property 'request' of undefined
node_modules is not embedeed in electron-builder package, a solution is to import all modules into the index.js entry point like describe bellow:
https://www.electron.build/tutorials/loading-app-dependencies-manually
Ok that is working now, after long seek the problem was that you have to push your "socket.io-client" into dependencies and not devDependencies.

Cannot find module after creating and adding plugin in Nativescript

Using the latest version of Nativescript I've created a plugin as per the documentation and after running tns plugin add ../nativescript-keychain I get the message Successfully installed plugin nativescript-keychain.
I can also see that it's been added to the node_modules directory of my app but require("nativescript-keychain") doesn't work as I get the error Cannot find module 'nativescript-keychain'
My plugin package.json looks like
{
"name": "nativescript-keychain",
"version": "0.0.1",
"nativescript": {
"platforms": {
"ios": "2.2.1"
}
}
}
There are several reasons why this might occur; it would be helpful if you provided a repo to see all the code.
package.json doesn't have a link to the source, typically you have a main: "somefile" key.
Did you do tns run ios --emulator after you installed the plugin, you have to rebuild the app before it will take effect, plugins can't be synced via livesync...
Is the code TypeScript or JavaScript, if it is TypeScript it needs to be transpiled to JS before you can add it to your demo application. TNS will NOT compile any TS code in the plugins. Plugins have to ship with the final JS code.
You need typings for TS to use the auto-complete and not throw warnings about what methods are available.

Resources