NPM Excluding files automatically > - node.js

I am trying to publish a package on npm. It's poppler's pdftotext portable.
The lib folder structure is like this:
"lib/libjpeg.so.9",
"lib/libjpeg.so.9.2.0",
"lib/libjpeg.so.9.2.0",
"lib/libpoppler.so",
"lib/libpoppler.so.98",
"lib/libpoppler.so.98.0.0"
but when I pack it, npm automatically removed other files and only keeps libjpeg 9.2.0 and libpoppler.so.98.0.0
Why are other files removed? There is no ignore file; no npmignore nor gigignore.
The type of removed file is Link to shared library (application/x-sharedlib) How can I include them as well ?
This is complete package.json
{
"name": "packname",
"version": "0.0.2",
"description": "dis",
"main": "index.js",
"directories": {
"lib": "lib"
},
"files": [
"bin",
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": ""
}

Related

"/" is not recognized as an internal or external command

Today, I'm coding a few npm packages and a few things that need to be prepared repeatedly.
So I wanted to code a CLI to get those things done quickly.
Here is the src/cli.js code:
export function cli(args){
console.log(args);
}
Here is the package.json code:
{
"name": "my-project",
"version": "1.0.0",
"description": "A CLI to bootstrap new project",
"main": "src/index.js",
"bin": {
"#kensoni/my-project": "bin/my-project",
"my-project": "bin/my-project"
},
"publishConfig": {
"access": "public"
},
"keywords": [
"cli"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Ken Nguyen",
"license": "MIT",
"dependencies": {
"arg": "^5.0.0",
"esm": "^3.2.25",
"inquirer": "^8.1.1"
}
}
Here is the bin/my-project code:
#!/usr/bin/env/ node
require = require('esm')(module /*, options*/);
require('../src/cli').cli(process.argv);
After I execute the command npm link and open a new cmd type my-project, I get the following message:
'"/"' is not recognized as an internal or external command,
operable program or batch file.
I am using these versions:
node: 14.17.1
npm: 7.18.1
Any ideas how it might work.
Thanks in advance.
Remove "/" after env
#!/usr/bin/env node
//...

npm link is not working, bash: dosmth: command not found

I am trying to do basic CLI with node, but seems like it is not linking from/to correct directory.
I have file named create, which contains command: console.log(process.cwd());
When I run in bash node create, it gives me that outcome:
/Users/katya/Desktop/code/drawer.
However, after running npm link (or sudo npm link), it prints that:
/Users/katya/.npm-packages/bin/dosmth -> /Users/katya/.npm-packages/lib/node_modules/drawer/create
/Users/katya/.npm-packages/lib/node_modules/drawer -> /Users/katya/Desktop/code/drawer
and after that if I run dosmth in bash I get:
bash: dosmth: command not found
I assume there is something to do with ./npm-packages/ appearing in the path.
I tried to delete node completely from computer and install again but did not help.
If you have any idea I would really appreciate your help.
My package.json:
{
"name": "drawer",
"version": "1.0.0",
"description": "",
"main": "index.js",
"bin": {
"dosmth": "create"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Have you tried changing bin to point to your index.js?
{
// Other keys ...
"bin": {
"dosmth": "./index.js"
},
//...
}

how to use cookiecutter-django scss

I used the recent cookiecutter django package to generate a new django product. But I am having trouble with the sass/scss compilation aspect.
I looked at this, and its no help, as I need to setup the package.json to run any commands.
I tried to make one, but I cannot seem to get it to run.
{
"name": "my_awesome_project",
"version": "1.0.0",
"description": "My Awesome Project ==================",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"scss": "sass --load-path my_awesome_project/static/sass/ my_awesome_project/static/css/a.css"
},
"author": "",
"license": "ISC",
"dependencies": {
"compass": "^0.1.1"
}
}
In all honesty, I don't really know what Im doing with this part, nor where to start.

npm install return: mongodb is not in the npm registry

I'm beginner in nodeJs I want to install the environment to make login page with mongodb,
I create this package.json:
{
"name": "loginapp",
"version": "1.0.0",
"description": "simple app",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "test test",
"license": "ISC",
"dependencies":{
"bcryptjs":"*",
"body-parser":"*",
"connect-flash":"*",
"cookie-parser":"^1.4.1",
"express":"*",
"express-handlebars":"*",
"express-messages":"*",
"express-session":"*",
"express-validator":"*",
"mongobd":"*",
"mongoose":"*",
"passport":"*",
"passport-http":"*",
"passport-local":"*"
}
}
and when I wanted to install with npm install I found this error :
img-error
thank's for helping ..

How to start my globally installed node application?

I developed small application.
I did this to install developed module globally:
npm install . -g
I got this response:
$ npm install -g .
update-deps-dev#1.0.0 C:\Users\Vladislav.Sharikov\AppData\Roaming\npm\node_modul
es\update-deps-dev
I got my module in place, where other globally installed modules are stored. Also, my module is available by:
npm ls -g --depth=0
Now, I want to start this module from any place on my pc. How should I do this?
I try to run, but getting this:
Vladislav.Sharikov#PC /D/Dev
$ update-deps-dev
sh: update-deps-dev: command not found
I am using Windows 7 x64 + Git Bash.
How should I start my globally installed node application?
My package.json file contents:
{
"name": "update-deps-dev",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"adm-zip": "^0.4.7",
"fs": "0.0.2",
"https": "^1.0.0",
"q": "^1.4.1",
"shelljs": "^0.7.0"
}
}
Not sure about git bash. But in a cross platform way you can simply define a bin field on your package json to tell npm to generate a binary available on your command line later. It really works fine on windows, mac, linux.
Note that it is a per user binary. If you are working on linux it won t install it into /usr/bin, but depending on your system, more probably ~/node_modules/bin.
Suppose your binary is defined into bin.js file, you just need to add a new Object field bin, and foreach bin you want to define a key, the name of the binary, and its value must point to the path of your bin file relative to the package file:
{
"name": "update-deps-dev",
"version": "1.0.0",
"description": "",
"main": "index.js",
"bin": {
"update-deps-dev": "./bin.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"adm-zip": "^0.4.7",
"fs": "0.0.2",
"https": "^1.0.0",
"q": "^1.4.1",
"shelljs": "^0.7.0"
}
}
Read also,
https://docs.npmjs.com/files/package.json#bin
https://docs.npmjs.com/cli/bin

Resources