permission needed to install serverless via npm - serverless-framework

I am trying to install serverless via npm (npm install -g serverless) but get the following error:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/serverless
npm ERR! dest /usr/local/lib/node_modules/.serverless-Ls3sFIzE
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/serverless' -> '/usr/local/lib/node_modules/.serverless-Ls3sFIzE'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/serverless' -> '/usr/local/lib/node_modules/.serverless-Ls3sFIzE'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/serverless',
npm ERR! dest: '/usr/local/lib/node_modules/.serverless-Ls3sFIzE'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
Does anyone know how to do this without having to switch the node versions you're using?
EDIT:
When I run this with sudo I get the following output:
npm WARN deprecated request-promise-native#1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid#3.3.2: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
changed 672 packages, and audited 673 packages in 25s
50 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
However, when I try to run serverless invoke local --function f1 I get zsh: command not found: serverless - after I install with sudo what do I need to do so that the command is recognised?

Your permissions are goofed. Speaking generally, you don't want to install anything from npm with sudo.
You can sudo chown yourUser:yourGroup -R /usr/local/lib/node_modules.
(If you're on macOS, your group is probably staff. You can find your group by running ls -l in your home directory and looking at the label adjacent to your username)
A simple alternative is a best practice anyway - install the serverless framework as a development dependency of your project:
npm i -D serverless
And then instead of running serverless deploy you can run npx serverless deploy.
Then as you check in the package.json file to version control, other collaborators will use the same version of the serverless framework.

Related

npm deprecated package problem, npm audit fix --force can not run

$ npm --version
8.0.0
$ npm i uncss -g
npm WARN deprecated request-promise-native#1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
changed 115 packages, and audited 116 packages in 2s
4 packages are looking for funding
run `npm fund` for details
1 moderate severity vulnerability
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
I got the above warnings. But I can not fix it as shown below. How to fix it?
$ npm audit fix --force
npm WARN using --force Recommended protections disabled.
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/myuser/.npm/_logs/2022-07-23T03_14_54_574Z-debug.log

issues with installing react native, npm install -g expo-cli gives warnings

I'm trying to install Expo CLI to set up the development environment for React Native but I keep getting this warning when I enter "npm install -g expo-cli" into my terminal:
npm WARN EBADENGINE required: { node: '>=12 <=16' },
npm WARN EBADENGINE current: { node: 'v18.2.0', npm: '8.9.0' }
Previously, trying to install Expo CLI with npm would throw errors like
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/expo-cli
npm ERR! dest /usr/local/lib/node_modules/.expo-cli-dKBr48UN
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/expo-cli' -> '/usr/local/lib/node_modules/.expo-cli-dKBr48UN'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/expo-cli' -> '/usr/local/lib/node_modules/.expo-cli-dKBr48UN'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/expo-cli',
npm ERR! dest: '/usr/local/lib/node_modules/.expo-cli-dKBr48UN'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
Then I tried the NVM solution in this post which asked me to uninstall node and then install NVM so that doing things like writing in my npm directory wouldn't ask for permission, but now I'm unsure what to do.
edit:
I followed this website to change my node version to v14.19.3 but now there are these warnings:
npm WARN deprecated subscriptions-transport-ws#0.9.8: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md
npm WARN deprecated graphql-tools#3.0.0: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as #graphql-tools/schema, #graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated svgo#1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated source-map-resolve#0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated source-map-url#0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated querystring#0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated chokidar#2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
/Users/zoeylee/.nvm/versions/node/v14.19.3/bin/expo -> /Users/zoeylee/.nvm/versions/node/v14.19.3/lib/node_modules/expo-cli/bin/expo.js
/Users/zoeylee/.nvm/versions/node/v14.19.3/bin/expo-cli -> /Users/zoeylee/.nvm/versions/node/v14.19.3/lib/node_modules/expo-cli/bin/expo.js
npm WARN ajv-keywords#3.5.2 requires a peer of ajv#^6.9.1 but none is installed. You must install peer dependencies yourself.
I'm a new user and programmer so any advice/help is appreciated, thanks!
You are using 18.2.0, but the message says it requires >=12 <=16 (greater than 12 and less than 16. Not 18.2.0 or greater.
If it's your package.json with the engines field causing this issue, change it to say 12.0.0 or greater:
"engines": {
"node": ">=12.0.0"
},

Error: Could not find expected browser (chrome) locally

I am trying to install aws-azure-login. I have to follow with Linux -> Option B: Install Only for Current User.
Then I ran this command:
sudo npm install -g aws-azure-login
I've got this output here:
GGNXFB3:~$ sudo npm install -g aws-azure-login
npm WARN deprecated uuid#3.3.2: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated querystring#0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
/usr/local/bin/aws-azure-login -> /usr/local/lib/node_modules/aws-azure-login/lib/index.js
> puppeteer#10.2.0 install /usr/local/lib/node_modules/aws-azure-login/node_modules/puppeteer
> node install.js
ERROR: Failed to set up Chromium r901912! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
{ [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/aws-azure-login/node_modules/puppeteer/.local-chromium']
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path:
'/usr/local/lib/node_modules/aws-azure-login/node_modules/puppeteer/.local-chromium' }
npm WARN notsup Unsupported engine for aws-azure-login#3.4.0: wanted: {"node":">=12.0"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: aws-azure-login#3.4.0
npm WARN notsup Unsupported engine for commander#8.1.0: wanted: {"node":">= 12"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: commander#8.1.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer#10.2.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer#10.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-18T00_37_04_178Z-debug.log
GGNXFB3:~$
Anyone has had success with this?
You need to make sure about the following things first:
Upgrade your Node.Js from 10.19.0 to >=12.0
Check if you have done the puppeteer dependency installation before npm installing aws-azure-login.
The list of required packages is listed here on puppeteer's Troubleshooting document per Linux system (Debian or CentOS). E.g.:
sudo apt-get install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 ...
(But make sure you add all the relevant packages!)

"npm start" wont work after "create-react-app"

I have tried everything. Looking at "PATH" variable in windows 10
-reinstalled node multiple times and multiple versions
-removed all node files and npm files from the program folder and the AppData and user folder.
-I finally got the react app to work but then when every I do "npm start" it gives me the errors.
-I have deleted node modules and package-lock.json file as well and still no solution.
PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1> npm start
> maryam1#0.1.0 start
> react-scripts start
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\Imran\Desktop\zertomastery\19_react\maryam1
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Imran\AppData\Local\npm-cache\_logs\2021-07-18T18_17_31_571Z-debug.log-debug.log
PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1>
I have deleted the node_modules folder and the package-lock.json and done npm install
-results of npm install after deleting node_modules and package.json.
PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1> npm start > npm install
npm WARN deprecated #hapi/bourne#1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated #hapi/topo#3.1.6: This version has
been deprecated and is no longer supported or maintained act\maryam1
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url#0.2.1: https://github.co find a file.om/lydell/resolve-url#deprecated
npm WARN deprecated querystring#0.2.1: The querystring
API is considered Legacy. new code should use the URLSearchParams API instead. 18_17_31_571Z-debug.log
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will bregs\2021-07-18Tak on node v14+. Upgrade to chokidar 3 with 15x less dependencies. >
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated querystring#0.2.0: The querystring
API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated sane#4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated #hapi/address#2.1.4: Moved to 'npm
install #sideway/address'
npm WARN deprecated babel-eslint#10.1.0: babel-eslint is now #babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated rollup-plugin-babel#4.4.0: This package has been deprecated and is no longer maintained. Please use #rollup/plugin-babel.
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random()
in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random()
in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated #hapi/hoek#8.5.1: This version has
been deprecated and is no longer supported or maintained
npm WARN deprecated #hapi/joi#15.1.1: Switch to 'npm install joi'
npm WARN deprecated core-js#2.6.12: core-js#<3.3 is no
longer maintained and not recommended for usage due to
the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a
slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of
core-js.
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\Imran\Desktop\zertomastery\19_react\maryam1\node_modules\core-js
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Imran\AppData\Local\npm-cache\_logs\2021-07-18T18_22_24_801Z-debug.log
PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1
after doing allot of commands and things I am not getting this when do "npm start" I switched to bash
Imran#DESKTOP-3331IKE MINGW64 ~/Desktop/zertomastery/19_react/maryam1 (main)
$ npm start
> maryam1#0.1.0 start
> react-scripts start
node:internal/modules/cjs/loader:355
throw err;
^
Error: Cannot find module 'C:\Users\Imran\Desktop\zertomastery\19_react\maryam1\node_modules\loader-runner\lib\LoaderRunner.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:347:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:560:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:913:27)
at Function.Module._load (node:internal/modules/cjs/loader:772:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (C:\Users\Imran\Desktop\zertomastery\19_react\maryam1\node_modules\webpack\lib\NormalModule.js:16:36)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
at Module.load (node:internal/modules/cjs/loader:975:32) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Users\\Imran\\Desktop\\zertomastery\\19_react\\maryam1\\node_modules\\loader-runner\\package.json',
requestPath: 'loader-runner'
}
Imran#DESKTOP-3331IKE MINGW64 ~/Desktop/zertomastery/19_react/maryam1 (main)
$
Try This,
npm cache clean
npm install
npm start

How can i install yeoman command line tool on ubuntu 20.04.1 LTS?

I tried installing yeoman command line tool in Ubuntu 20.04.1 LTS for ASP.NET Core web application development. After typing
npm install -g yo in terminal, i got an error.
Description of error is provided below.
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated cross-spawn-async#2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN checkPermissions Missing write access to /usr/local/lib
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/shashankshekhar/.npm/_logs/2020-12-21T11_02_14_859Z-debug.log```
The issue of EACCES errors on global module installation is so common that npm has an entire web page dedicated to solving just this issue.
Since you are installing yeoman, I imagine this is a development machine. In that case, your best bet is likely to install node/npm with a package manager like nvm.
One thing you don't want to do but that people will often suggest is running the npm command with sudo. People recommend this because it's easy. But if you do that, all the lifecycle scripts (e.g., postinstall) of the dependencies of whatever you are installing will also be run as root. That's potentially a lot of untrusted code running as root.