why there is a "node_module" folder in #uirouter/angular/? - node.js

I have a angularjs1.6.7 app depending on below lib:
"#uirouter/angular": "^1.0.1",
"#uirouter/angular-hybrid": "^3.1.10",
"#uirouter/angularjs": "^1.0.15",
"#uirouter/core": "^5.0.17",
"#uirouter/rx": "^0.4.5",
when I run command "npm run build" , it generates node_module like below:
E:\20-work\06-svn\datarein\01-Dev\branches\dev\datarein\ui\ui-app\node_modules\#uirouter\angular
2019/10/10 14:47 <DIR> .
2019/10/10 14:47 <DIR> ..
2017/08/13 10:43 71 artifacts.json
2018/05/03 12:24 117,843 CHANGELOG.md
2017/04/23 05:53 3,982 CONTRIBUTING.md
2018/01/02 03:12 266 downstream_projects.json
2018/03/28 04:56 1,677 karma.conf.js
2019/10/10 14:44 <DIR> lib
2017/04/05 11:42 1,102 LICENSE
2019/10/10 14:47 <DIR> node_modules
2019/10/10 14:47 4,031 package.json
2017/12/27 09:15 1,750 README.md
2018/04/20 09:35 886 typedoc.json
2019/10/10 14:44 <DIR> _bundles
and in the above "angular/node_modules" there is another #uirouter/core folder :
E:\20-work\06-svn\datarein\01-Dev\branches\dev\datarein\ui\ui-app\node_modules\#uirouter\angular\node_modules\#uirouter\core>dir
2019/10/10 14:47 <DIR> .
2019/10/10 14:47 <DIR> ..
2018/02/08 08:26 86 artifacts.json
2018/04/30 06:58 102,786 CHANGELOG.md
2017/09/21 11:11 3,771 CONTRIBUTING.md
2018/02/08 08:27 459 downstream_projects.json
2019/10/10 14:45 <DIR> lib
2019/10/10 14:44 <DIR> lib-esm
2017/09/21 11:11 1,102 LICENSE
2019/10/10 14:47 4,147 package.json
2018/02/08 08:27 3,261 README.md
2018/04/30 02:18 804 typedoc.json
2019/10/10 14:44 <DIR> _bundles
I am guessing it cause below error
error TS2345: Argument of type 'StateDeclaration' is not assignable to parameter of type 'StateOrName'.
Type 'import("/ui-app/node_modules/#uirouter/core/lib/state/interface").StateDeclaration' is not assignable to type 'import("/ui-app/node_modules/#uirouter/angular/node_modules/#uirouter/core/lib/state/interface").StateDeclaration'.
Types of property 'parent' are incompatible.
Would someone help to advise?
env spec:
windows10,
node 6.4.1
angularjs 1.6.7

Related

Some executable files show "no such file or directory" after run in docker, while some are not

This is my Dockerfile:
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY ls .
COPY tail .
COPY test .
COPY manager .
ENTRYPOINT ["/manager"]
after
[root#master go-docker-test]# docker build -t strangething:v1.13 .
[root#master go-docker-test]# docker run -d strangething:v1.13
[root#master go-docker-test]# docker logs b2
it shows:
exec /manager: no such file or directory
I'm pretty sure it is there. I use dive to see it:
[Layers]───────────────────────────────────────────────────────────────────── [● Current Layer Contents]──────────────────────────────────────────────────
Cmp Image ID Size Command Permission UID:GID Size Filetree
sha256:cb60fb9b862c6a89f9 2.3 MB FROM sha256:cb60fb9b862c6a89f9 drwxr-xr-x 0:0 2.3 MB ├── .
sha256:3e884d7c2d4ba9bac6 118 kB COPY ls . # buildkit drwxr-xr-x 0:0 0 B │ ├── bin
sha256:e75e9da8f1605f7944 67 kB COPY tail . # buildkit drwxr-xr-x 0:0 0 B │ ├── boot
sha256:7a0f1970f36a364672 1.8 MB COPY test . # buildkit drwxr-xr-x 0:0 0 B │ ├── dev
sha256:c9ab59cb1ce11477ca 47 MB COPY manager . # buildkit drwxr-xr-x 0:0 220 kB │ ├─⊕ etc
drwxr-xr-x 65532:65532 0 B │ ├─⊕ home
[Layer Details]────────────────────────────────────────────────────────────── drwxr-xr-x 0:0 0 B │ ├── lib
drwxr-xr-x 0:0 0 B │ ├── proc
Digest: sha256:c9ab59cb1ce11477cac4d634bb81cf7316c344b50f01a62a8e5ddcf355d5fe drwx------ 0:0 0 B │ ├── root
cf drwxr-xr-x 0:0 0 B │ ├── run
Tar ID: 998c57d00785ccffaf3b308a529c7f816633897097d1ef6519269a8e3c5af59b drwxr-xr-x 0:0 0 B │ ├── sbin
Command: drwxr-xr-x 0:0 0 B │ ├── sys
COPY manager . # buildkit drwxrwxrwx 0:0 0 B │ ├── tmp
drwxr-xr-x 0:0 2.1 MB │ ├─⊕ usr
[Image Details]────────────────────────────────────────────────────────────── drwxr-xr-x 0:0 1.8 kB │ └─⊕ var
-rwxr-xr-x 0:0 118 kB ├── ls
Total Image size: 51 MB -rwxr-xr-x 0:0 47 MB ├── manager
Potential wasted space: 0 B -rwxr-xr-x 0:0 67 kB ├── tail
Image efficiency score: 100 % -rwxr-xr-x 0:0 1.8 MB └── test
Count Total Space Path
This file tree confuses me more or less.
Anyway, strange thing is, ls tail manager can't exec, but testcan exec.
after I change ENTRYPOINT ["/manager"] to ENTRYPOINT ["/test"]:
[root#master go-docker-test]# docker logs c11
empty
test is a program built by test.go, I write it myself:
package main
import (
"fmt"
)
type Per struct {
Name string
Age int
}
type Person struct {
Name string
Age int
Lov Per
}
func main() {
var one Person
one.Name="abc"
one.Age=11
var two Per
one.Lov=two
if one.Lov != (Per{}){
fmt.Println("not empty!")
}else {
fmt.Println("empty")
}
}
After reading silh's comment and the kubebuilder Dockerfile again, I somehow solved this problem by adding CGO_ENABLED=0 to go build. It changes dynamic linker to static linker.
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
At least the no such file or directory error is now gone.

How to customise Buildroot external modules

I am trying to make two/multiple custom modules outside buildroot directory and build them whenever needed. Tree as below,
buildroot
kernel_module
├── Config.in
├── external.desc
├── external.mk
├── package
│   └── kernel-modules
│   ├── Config.in
│   ├── kernel-modules.mk
│   ├── kmod-example
│   │   ├── Config.in
│   │   ├── kmod-example.c
│   │   ├── kmod-example.mk
│   │   ├── Makefile
│   └── kmod-notifier-exmp
│   ├── Config.in
│   ├── kmod-notifier-exmp.c
│   ├── kmod-notifier-exmp.mk
│   ├── Makefile
├── readme
added this config to .config
make BR2_EXTERNAL=/home/beaglebone_black/buildroot/kernel_module beaglebone_defconfig
Then I can see external options enabled in make menuconfig.
The issue is if I execute,
make kmod-notifier-exmp
this doesnt rsync my local configurations and fails saying,
buildroot/output/build/kmod-notifier-exmp/./Makefile: No such file or directory
contents generated as below
❯ cd output/build/kmod-notifier-exmp
❯ ls -la
total 788
drwxr-xr-x 2 n n 4096 Dec 24 19:34 .
drwxr-xr-x 61 n n 4096 Dec 24 19:34 ..
-rw-r--r-- 1 n n 0 Dec 24 19:32 .applied_patches_list
-rw-r--r-- 1 n n 300823 Dec 24 19:32 .files-list.before
-rw-r--r-- 1 n n 93604 Dec 24 19:32 .files-list-host.before
-rw-r--r-- 1 n n 724 Dec 24 19:32 .files-list-images.before
-rw-r--r-- 1 n n 395450 Dec 24 19:32 .files-list-staging.before
-rw-r--r-- 1 n n 0 Dec 24 19:32 .stamp_configured
-rw-r--r-- 1 n n 0 Dec 24 19:32 .stamp_downloaded
-rw-r--r-- 1 n n 0 Dec 24 19:32 .stamp_extracted
-rw-r--r-- 1 n n 0 Dec 24 19:32 .stamp_patched
for make kmod-example it rsyncs, but it sync kmod-notifier-exmp files and build fails.
Keeping single module works but not multiple modules.
How to solve this issue?
Solution to above problem is naming convention in final *.mk file. If we want to make another module named foo, naming convention have to follow as below,
foo.mk
FOO_VERSION = 1.0
FOO_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/package/kernel-modules/foo
FOO_SITE_METHOD = local
$(eval $(kernel-module))
$(eval $(generic-package))
as above I was facing problem with kmod-notifier-exmp package so its *.mk will be as below
kmod-notifier-exmp.mk
KMOD_NOTIFIER_EXMP_VERSION = 1.0
KMOD_NOTIFIER_EXMP_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/package/kernel-modules/kmod-notifier-exmp
KMOD_NOTIFIER_EXMP_SITE_METHOD = local
$(eval $(kernel-module))
$(eval $(generic-package))

Creating a file in a folder

How do I create a file in a certain folder in Rust?
I have tried the following approaches:
let f = File::create(Path::new(format!("{}{}","/files/",filename).as_str()));
let f = File::create(format!("{}{}","/files/",filename));
Both result in:
The system cannot find the path specified. (os error 3)
I have managed to create the file in the same directory as the executable with:
let f = File::create(format!("{}",filename));
So how do I go about creating files in a specific directory?
ls on basefolder:
PS C:\trust\svd2rust\target\debug> ls
Directory: C:\trust\svd2rust\target\debug
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2017-01-24 12:13 .fingerprint
d----- 2017-01-24 12:13 build
d----- 2017-01-26 10:06 deps
d----- 2017-01-24 12:13 examples
d----- 2017-01-26 07:18 files
d----- 2017-01-24 12:13 incremental
d----- 2017-01-24 12:13 native
-a---- 2017-01-24 12:13 0 .cargo-lock
-a---- 2017-01-26 10:06 1079240 libsvd2rust.rlib
-a---- 2017-01-24 21:08 27608 log.rs
-a---- 2017-01-24 13:55 27372 log2.rs
-a---- 2016-08-23 15:07 565888 STM32F401x.svd
-a---- 2016-08-23 15:07 912360 STM32F401xE.svd
-a---- 2016-08-23 15:07 1907985 STM32F40x.svd
-a---- 2017-01-26 10:06 11761561 svd2rust.exe
Using "files/" instead of "/files/" solved the problem.
It seems "/files/" references to the absolute path of C:\files, while "files/" references to the relative path of the executable.
So when using "/files/" it did't work since there was no folder C:\Files.

tsc ignores my tsconfig.json file

When I run tsc in my project's directory it outputs an error (reproduced later)
This is the first time I'm trying typescript and nodejs. You can safely assume I'm a total beginner.
ubuntu 15.10 64bits
npm version 2.4.12
node version v4.3.1
tsc version 1.7.5
system locale fr_FR.UTF-8
Compiler output :
/data/code/tsrest$ tsc
/usr/lib/node_modules/typescript/lib/tsc.js:31084
var jsonOptions = json["compilerOptions"];
^
TypeError: Cannot read property 'compilerOptions' of undefined
at getCompilerOptions (/usr/lib/node_modules/typescript/lib/tsc.js:31084:35)
at Object.parseJsonConfigFileContent (/usr/lib/node_modules/typescript/lib/tsc.js:31074:22)
at parseConfigFile (/usr/lib/node_modules/typescript/lib/tsc.js:31351:40)
at performCompilation (/usr/lib/node_modules/typescript/lib/tsc.js:31362:45)
at Object.executeCommandLine (/usr/lib/node_modules/typescript/lib/tsc.js:31336:9)
at Object.<anonymous> (/usr/lib/node_modules/typescript/lib/tsc.js:31635:4)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
Project layout:
-rw-rw-r-- 1 220 févr. 20 17:15 package.json
-rw-rw-r-- 1 375 févr. 20 17:39 tsconfig.json
-rw-rw-r-- 1 70 févr. 20 17:23 typings.json
build:
total 8
drwxrwxr-x 2 4096 févr. 20 17:16 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
client:
total 8
drwxrwxr-x 2 4096 févr. 20 17:16 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
server:
total 12
drwxrwxr-x 2 4096 févr. 20 17:18 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
-rw-rw-r-- 1 298 févr. 20 16:59 tsrest.ts
typings:
total 8
drwxrwxr-x 2 4096 févr. 20 17:23 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
-rw-rw-r-- 1 0 févr. 20 17:23 browser.d.ts
-rw-rw-r-- 1 0 févr. 20 17:23 main.d.ts
Some of the things I've tried:
cd tsrest
npm init -y
mkdir server build client
(editing tsconfig.json and server/tsrest.ts from a tutorial)
tsc
Outputs the error
sudo npm install -g typings
typings install
tsc
Well that didn't help either.
cd server/
tsc
cd ..
Now I thought my tsconfig.json was not good.
rm tsconfig.json
tsc --init
ll
tsc
Same error ...
Contents of tsconfig.json:
{
"version": "1.7.5",
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"outDir": "built",
"rootDir": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
// "sourceMap": false
},
"exclude": [
"node_modules",
"client" // 4
]
}
Contents of package.json:
{
"name": "tsrest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
I ran tsc with strace to see if it access tsconfig:
(start omitted)
1531 getcwd("/data/code/tsrest", 4096) = 18
1531 stat("tsconfig.json", {st_mode=S_IFREG|0664, st_size=375, ...}) = 0
1531 stat("tsconfig.json", {st_mode=S_IFREG|0664, st_size=375, ...}) = 0
1531 open("tsconfig.json", O_RDONLY|O_CLOEXEC) = 9
1531 fstat(9</data/code/tsrest/tsconfig.json>, {st_mode=S_IFREG|0664, st_size=375, ...}) = 0
1531 read(9</data/code/tsrest/tsconfig.json>, "{\n \"version\": \"1.7.5\",\n \"c"..., 375) = 375
1531 close(9</data/code/tsrest/tsconfig.json>) = 0
1531 mmap(0x320402100000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x320402100000
1531 mmap(0x320403100000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x320403100000
1531 munmap(0x7f35b90bd000, 1568768) = 0
1531 write(2</dev/pts/1>, "/usr/lib/node_modules/typescript"..., 892) = 892
1531 exit_group(1) = ?
Note that tsconfig.json is 375 bytes, so the read call reads all of it.
So I figured that tsc doesn't parse the JSON file. I edited the file to see if there was anything funny. Only thing that standed out was the comments so I removed them and tried tsc again.
This time it worked.
I'll submit a ticket so that in case tsc can't parse the config file a better error is given.
Support for comments in tsconfig.json has been added recently and is on the milestone for TS 1.8. Here is the link to the issue in GitHub. I was able to reproduce this issue on Ubuntu with Typescript 1.7.5 but if you install TypeScript#next, which is 1.9 in development, comments are accepted with out issues. You would need to wait until TS 1.8 is released to be able to have comments in tsconfig.json.

Code fails sometimes and runs sometimes

I am a newbie as far as node.js is concerned.I wrote the following code to pipeline two linux commands.
This is my nodejs code:
var spawn = require('child_process').spawn,
ls = spawn('ls',['-lh','/usr']),
grep = spawn('grep',['bin']);
/*
ls.stdout.on('data',function(data){
console.log('stdout: '+data);
});
*/
ls.stdout.on('data',function(data){
console.log(""+data);
grep.stdin.write(data);
});
ls.stderr.on('data',function(data){
console.log('stderr: '+data);
});
ls.on('exit',function(code){
console.log('Exit code '+code);
grep.stdin.end();
})
// ------------------------------------
grep.stdout.on('data',function(data){
console.log('stdout: '+data);
});
grep.stderr.on('data',function(data){
console.log('stderr: '+data);
});
Now this code fails sometimes and runs sometimes.I'm getting confused now.
When it fails,it says:
Exit code 0
total 160K
drwxr-xr-x 2 root root 68K Oct 12 12:54 bin
drwxr-xr-x 2 root root 4.0K Jun 20 19:58 games
drwxr-xr-x 54 root root 4.0K Sep 24 17:52 include
drwxr-xr-x 252 root root 44K Oct 2 21:53 lib
drwxr-xr-x 10 root root 4.0K Apr 28 19:16 local
drwxr-xr-x 2 root root 12K Sep 18 15:51 sbin
drwxr-xr-x 362 root root 12K Sep 28 17:58 share
drwxr-xr-x 5 root root 4.0K Jul 7 23:39 src
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._write (net.js:517:19)
at Socket.write (net.js:509:15)
at Socket.<anonymous> (/home/rajat/nodexperiments/full-spawn.js:13:13)
at Socket.EventEmitter.emit (events.js:88:17)
at Pipe.onread (net.js:395:14)
And when it runs,it says:
total 160K
drwxr-xr-x 2 root root 68K Oct 12 12:54 bin
drwxr-xr-x 2 root root 4.0K Jun 20 19:58 games
drwxr-xr-x 54 root root 4.0K Sep 24 17:52 include
drwxr-xr-x 252 root root 44K Oct 2 21:53 lib
drwxr-xr-x 10 root root 4.0K Apr 28 19:16 local
drwxr-xr-x 2 root root 12K Sep 18 15:51 sbin
drwxr-xr-x 362 root root 12K Sep 28 17:58 share
drwxr-xr-x 5 root root 4.0K Jul 7 23:39 src
Exit code 0
stdout: drwxr-xr-x 2 root root 68K Oct 12 12:54 bin
drwxr-xr-x 2 root root 12K Sep 18 15:51 sbin
Any Ideas?
This is quite clearly a race condition, because node.js is a highly parallel environment you have found a really nice example to demonstrate this.
ls.on('exit',function(code){
console.log('Exit code '+code);
grep.stdin.end();
})
ls fires the above event, before it has finished writing to grep, and then closes the socket that's being used to communicate. The hint your output gives you is that the exit(0) message coming from ls appears once at the top of the output, and once just above the error message.
You shouldn't be closing grep's stdin channel here.
But what about using .exec() instead of spawn on a bash script that does something like
#/bin/bash mybashscript
ls $1 | grep bin
and then using the JavaScript closure, such as
child = exec('mybashscript',['-lh','/usr']
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
With the events your code ordering is more difficult to read.

Resources