can't install npm package in google cloud functions - node.js

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.

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?

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

How to fix the "npm install error" when installing "Botkit"?

I am a newbie machine learning programmer trying get how to install the botkit tool for creating AI messaging bots from the bot kit studio.
Botkit was installed but the following errors are shown in my terminal:
Rakeshs-MacBook-Air:~ niharika$ npm install
npm WARN enoent ENOENT: no such file or directory, open '/Users/niharika/package.json'
npm WARN niharika No description
npm WARN niharika No repository field.
npm WARN niharika No README data
npm WARN niharika No license field.
Rakeshs-MacBook-Air:~ niharika$ npm install --productions
npm WARN enoent ENOENT: no such file or directory, open '/Users/niharika/package.json'
npm WARN niharika No description
npm WARN niharika No repository field.
npm WARN niharika No README data
npm WARN niharika No license field.
I can't seem to figure out what the package.json file is supposed to be in order to run botkit studio.
This error does not have much to do with Botkit, but more to do with where you are running the npm install. You are running it in your /Users/niharika path. If you cloned down botkit into that directory then you will need to cd into it first. Your path will look more like /Users/niharika/botkitslackstarter/. Then run npm install which will look for a package.json in the root and install all dependencies so then you will be able to run node bot.js to start the application. Best of luck.
Step 1:
npm install
Step 2:
npm install botkit

Resources