install a node js package from tar - node.js

I have created a tar file from my entire package directory including the package file and try to use the command
npm install package.tar
from my projects folder where the tar file is, however I am getting an error that says:
ENOENT: no such file or directory, open 'C:\Projects\package.json'
If I try to put the package.json file in projects folder, I get:
Refusing to install package as a dependency of itself
C:\Projects>npm install nodeTest.tar
C:\Projects
`-- node-test#1.0.0
npm WARN enoent ENOENT: no such file or directory, open
'C:\Projects\package.json'
npm WARN Projects No description
npm WARN Projects No repository field.
npm WARN Projects No README data
npm WARN Projects No license field.
How exactly do I install a package from a tar file?
I just want to be able to install a package from a file without pulling from published online npm packages

Related

how to get the dependencies of a project with a package-lock.json but no package.json?

I have a project with a package-lock.json but no package.json.
When I run npm install I get the following:
npm WARN saveError ENOENT: no such file or directory, open '/home/neubert/myproject/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/neubert/myproject/package.json'
npm WARN myproject No description
npm WARN myproject No repository field.
npm WARN myproject No README data
npm WARN myproject No license field.
up to date in 0.279s
found 0 vulnerabilities
Any ideas how I can make it so that the deps in the package-lock.json are downloaded, even if package.json isn't present?
Well my first thought would be to run
npm rebuild
If you have installed previously it will rebuild all the packages and they will print out on your screen. Then its just a matter of adding them back to a package.js
here is a link to npmjs.com and their cli commands... its handy. i have it bookmarked in my cheat sheets

Getting error: "saveError ENOENT: no such file or directory, open '.../package.json'

I am attempting to install newsapi via the command: npm install newsapi --save.
That installs two dependent packages (core-js and node-fetch) as well as newsapi itself. I run the command in my project folder. I have no issues with core-js and node-fetch, but I get the following warnings regarding newsapi.
npm WARN saveError ENOENT: no such file or directory, open 'Users/user_name/project/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'Users/user_name/project/package.json'
npm WARN project No description
npm WARN project No repository field.
npm WARN project No README data
npm WARN project No license field.
After the installation, package-lock.json is created in my project folder and Users/user_name/project/node-modules/newsapi/package.json does exist. I don't know why the installation asks me to open Users/user_name/project/package.json. Why would it be in my project folder and not in the module's folder?
I tried solutions I read in other threads including deleting package-lock.json and retrying the installation and using npm init. Neither of those methods worked.
I also tried copying and pasting package.json to the project folder (because the warnings prompt me to open Users/user_name/project/package.json) but that did not solve my problems either.
How can I successfully install the module?

can't install npm package in google cloud functions

I am new in using google cloud functions. I am trying to use expressjs in the my google cloud functions folder. I run npm i express on my terminal. but I get errors like this
npm WARN saveError ENOENT: no such file or directory, open '/Users/muchammadagunglaksana/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/muchammadagunglaksana/package.json'
npm WARN muchammadagunglaksana No description
npm WARN muchammadagunglaksana No repository field.
npm WARN muchammadagunglaksana No README data
npm WARN muchammadagunglaksana No license field.
+ express#4.17.1
updated 1 package and audited 17547 packages in 4.294s
it seems the package is installed, but the express dependecies is not automatically added on package.json
Change directory (cd) to your functions folder before running the command. npm assumes that package.json is in the current working directory in order to make changes to it.

Module 'googleapis' is not listed as dependency in package.json

Step 1: I try to add googleapis as dependency and got the error
$ npm install googleapis
npm WARN saveError ENOENT: no such file or directory, open '[home]/package.json'
npm WARN enoent ENOENT: no such file or directory, open '[home]/package.json'
npm WARN saly No description
npm WARN saly No repository field.
npm WARN saly No README data
npm WARN saly No license field.
Question: Why is it looking for the file in my home directory as opposed to my project directory? Especially since I am making the call from my project directory.
Step 2: I misunderstood the error and proceeded to deploying my project and that's where I got the error
Module 'googleapis' is not listed as dependency in package.json
Step 3: I now try npm i googleapis --save but I still get the same errors as in steps 1 and 2.
It seems that the problem was due to that I forgot to cd into the functions directory before I tried to install the dependencies.

npm install from tgz created with npm pack

I've created a .tgz file with npm pack. When trying to install it npm prints out the following error:
D:\tmp>npm install package-0.0.1.tgz
npm WARN saveError ENOENT: no such file or directory, open 'D:\tmp\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\tmp\package.json'
npm WARN tmp No description
npm WARN tmp No repository field.
npm WARN tmp No README data
npm WARN tmp No license field.
It looks like npm for some reason does not extract the contents of my .tgz package, meaning all the .js files, package.json etc. although everything is there. Apparently it only tries to install the dependencies listed in my package.
Should it really work this way or I'm doing something wrong?
This error means you are not in a directory that has a package.json file and you are using the command that installs a package as a dependency into an existing, (local) npm project's package.json.
To install your package globally (just to test if it can be installed):
npm install -g package-0.0.1.tgz
Or, if you want to install/add it as a dependency to some other npm project (like a test harness), first make sure that npm project has a package.json, and then :
test-harness-dir> npm install package-0.0.1.tgz

Resources