Mithrill Error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>' - mithril.js

I am new to Mithril. I am trying to follow this example for a pretty basic start: https://github.com/spacejack/mithril-ts-example. Here are my package.json, and tsconfig.json :
# package.json
{
"dependencies": {
"browserify": "^17.0.0",
"budo": "^11.6.4",
"mithril": "^2.0.4",
"tsify": "^5.0.4"
},
"devDependencies": {
"#types/mithril": "github:MithrilJS/mithril.d.ts#next"
},
"name": "web_client",
"version": "1.0.0",
"main": "index.ts",
"scripts": {
"compile": "browserify --debug src/main.ts -p [ tsify --project ./src/tsconfig.json ] -o public/js/app.js",
"build": "browserify src/main.ts -p [ tsify --project ./src/tsconfig.json ] | uglifyjs -cm -o public/js/app.js",
"clean": "rm -f public/js/app.js",
"start": "budo src/main.ts:js/app.js -p 3000 --dir public --live=*.{html,js,css} -- --debug -p [ tsify --project ./src/tsconfig.json ]"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
# tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"esModuleInterop": true,
"lib": ["dom", "es2015"],
"strict": true
},
"files": ["./main.ts"]
}
Finally, here is my traceback:
web_client npm start
> web_client#1.0.0 start
> budo src/main.ts:js/app.js -p 3000 --dir public --live=*.{html,js,css} -- --debug -p [ tsify --project ./src/tsconfig.json ]
[0000] info Server running at http://192.168.1.60:3000/ (connect)
[TypeScript error: /home/nina/Documents/school/AREA/web_client/node_modules/#types/mithril/index.d.ts(28,44): Error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.] {
fileName: '/home/nina/Documents/school/AREA/web_client/node_modules/#types/mithril/index.d.ts',
line: 28,
column: 44
}
[0000] info LiveReload running
[0000] info LiveReload filtering filenames with glob: *.%7Bhtml,js,css%7D
I have search everywhere but it seems that nobody had the exact same error as me. What did I do wrong?

Related

how to use react-native-config to set environment variable in nx?

I want to use react-native-config to set environment variable with nx. Is it possible to combine this two package together to achieve the goal? or just use nx environment variable setting. Any suggestion is appreciated.Thanks.
I want to use #nrwl/workspace:run-commands to run my customize script.
"customCommand": {
"executor": "nx:run-commands",
"options": {
"command": "react-native run-android"
}
}
when I run the command in command line.
npx nx run employee:make
It shows below error
TypeError: Cannot read properties of undefined (reading 'options')
Not sure you want to run in libs or apps. I assume you try to run command in libs. Your project.json look like that:
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/assets/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "#nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/assets/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "#nrwl/jest:jest",
"outputs": ["coverage/libs/assets"],
"options": {
"jestConfig": "libs/assets/jest.config.ts",
"passWithNoTests": true
}
}
}
}
and add your command:
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/assets/src",
"projectType": "library",
"tags": [],
"targets": {
"customCommand": {
"executor": "nx:run-commands",
"options": {
"command": "react-native run-android"
}
},
"lint": {
"executor": "#nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/assets/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "#nrwl/jest:jest",
"outputs": ["coverage/libs/assets"],
"options": {
"jestConfig": "libs/assets/jest.config.ts",
"passWithNoTests": true
}
}
}
}
run your command with:
nx run assets:customCommand
in case cmd not found run code below and try again:
nx reset

Can someone help me resolve this problem? Fatal error: Unable to find local grunt

I am learning hybris and I started using smartedit. The problem is that when I run ant clean all or ant updatesystem I get this error.
Running grunt default
grunt-cli: The grunt command line interface (v1.3.2)
Fatal error: Unable to find local grunt.
If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:
https://gruntjs.com/getting-started
What have I done till now:
I have grunt-cli installed globally, and grunt installed locally. Also, I run npm install.
Here is my packege.json file:
{
"name": "name",
"version": "1.0.0",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^1.4.1",
"grunt-contrib-jshint": "^3.0.0",
"grunt-contrib-watch": "^1.1.0"
},
"dependencies": {},
"description": "desc"
}
Here is my Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
globals: {
jQuery: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['jshint']);
};
I tried a bunch of ways to resolve this problem but nothing seemed to work. Can someone help me out?

Npm Publish Issue - Artifactory

I am publishing an npm library to an npm repo on artifactory. The library is built using angular and the dist folder and package.json looks correct. When publishing, the request it's self is published but not the actual artifact.
All i see on artifactory is a single file and not a folder containing my package
Running
npm publish
Package.json
{
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.0",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
}
}
What actually gets published to artifactory in a single file.
{
"_id": "#abce/embedded-auth",
"name": "#abce/embedded-auth",
"dist-tags": {
"latest": "1.0.0-dev.1"
},
"versions": {
"1.0.0-dev.1": {
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.1",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce-auth.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
},
"readme": "ERROR: No README data found!",
"_id": "#abce/embedded-auth#1.0.0-dev.1",
"_npmVersion": "6.4.1",
"_nodeVersion": "10.15.3",
"_npmUser": {
"name": "deployment",
"email": "bob#bob.ie"
},
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"dist": {
"integrity": "sha512-rpTN1sMpwnMwehzWUqbV+zElzaOlF5ekQRCQMncy6c+i4TAp5jbBobvzrhgl0ORqHgJn3Eo+EcrRgYLSjV7MdQ==",
"shasum": "71f654dd5fddb20a9d5063171d5293424a4271c7",
"tarball": "http://abce.jfrog.io/abce/internal-npm-dev/#abce/embedded-auth/-/#abce/embedded-auth-1.0.0-dev.1.tgz"
}
}
},
"readme": "ERROR: No README data found!",
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"_attachments": {
"#abce/embedded-auth-1.0.0-dev.1.tgz": {
"content_type": "application/octet-stream",
"data": "correctly populated tarball base64 data here. I checked it and it is correct",
"length": 12092
}
}
}
Expect:
I would expect the package to be parsed from the request and the package published correctly
Actual:
The put request data from the npm publish command is published as a file
npm version: 6.9.0
node version: v12.3.1(has also been run with 10.15.3)
Any ideas?
Please check the registry URL that you are using from npm, if it doesn't include /api/npm - it is invalid.
Wrong URL: https://domain/artifactory/some-directory/.
Valid URL: https://domain/artifactory/api/npm/some-directory/.

Unable to resolve 'react-navigation'

Am trying out react-native and get below error, when I install and try to use react-navigation (import {StackNavigator} from 'react-navigation';).
Error
I use the following command to install "react-navigation" : npm install --save react-navigation
On running above command I get 'react-navigation' folder under node_modules folder, with just a single file (package.json). Below is the content of the file:
{
"_args": [
[
{
"raw": "react-navigation#0.0.0",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"/Users/rakesh-1812/Documents/REACT_JS/SimpleApp"
]
],
"_from": "react-navigation#0.0.0",
"_id": "react-navigation#0.0.0",
"_inCache": true,
"_location": "/react-navigation",
"_nodeVersion": "4.2.1",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/react-navigation-0.0.0.tgz_1459892254509_0.1584461957681924"
},
"_npmUser": {
"name": "ericvicenti",
"email": "ericvicenti#gmail.com"
},
"_npmVersion": "2.14.7",
"_phantomChildren": {},
"_requested": {
"raw": "react-navigation#0.0.0",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz",
"_shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"_shrinkwrap": null,
"_spec": "react-navigation#0.0.0",
"_where": "/Users/rakesh-1812/Documents/REACT_JS/SimpleApp",
"dependencies": {},
"description": "Coming Soon",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"tarball": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz"
},
"maintainers": [
{
"name": "ericvicenti",
"email": "ericvicenti#gmail.com"
}
],
"name": "react-navigation",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"scripts": {},
"version": "0.0.0"
}
Can someone please help me resolve the issue. Thanks in advance.
React navigation is still in beta. It works for me when I use the command:
npm install --save react-navigation#1.0.0-beta.7
This is the latest release. https://github.com/react-community/react-navigation/releases
You must stop your node server and start it again.
Do it:
sudo lsof -n -i4TCP:8081 | grep LISTEN
It will listen of the services that are running on port 8081. By default, react native server runs on it. Then, execute the command below to kill the server process.
kill -9 <cma process id>
Finally, run your project again with
react-native run-ios
on the project folder
I was unable to install react-native, tried everything from the internet. Using Yarn instead of npm resolved the problem.
Try installing react-navigation stack, npm i react-navigation-stack. Then import {createStackNavigator} from 'react-navigation-stack'
Stop the server and run your project again.

npm run script causes Windows Script Host error

I a trying to use npm to minify javascript.
This is my package.json:
{
"name": "name1",
"version": "1.0.0",
"description": "",
"scripts": {
"minifyjs": "minifyJs",
"minifycss": "minifyCss",
"minifyhtml": "minifyHtml"
},
"author": "",
"license": "ISC",
"devDependencies": {
"clean-css": "^3.4.19",
"html-minifier": "^3.0.2",
"uglify-js": "^2.7.0"
}
}
and my minifyJs script is :
var uglifyJS = require('uglify-js');
var fs = require('fs');
var result = uglifyJS.minify(['src/main1.js', 'src/main2.js'], {
compress: {
drop_console: true,
unused: true
}
});
fs.writeFileSync('dist/minifyJs.js', result.code);
When I call npm run minifyjs I get the following error:
What am I doing wrong - btw this was working on another machine.....
Can anyone help?
The entries under scripts are commands that are run by NPM. They are not simply paths to JavaScript files.
You need to tell NPM to run your JavaScript tasks using node:
...
"scripts": {
"minifyjs": "node minifyJs",
"minifycss": "node minifyCss",
"minifyhtml": "node minifyHtml"
},
...