PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label npm-install. Show all posts
Showing posts with label npm-install. Show all posts

Friday, October 21, 2022

[FIXED] How do I fix the npm UNMET PEER DEPENDENCY warning?

 October 21, 2022     angularjs, angularjs-material, node.js, npm, npm-install     No comments   

Issue

I'm on Windows 10, with Node 5.6.0 and npm 3.6.0. I'm trying to install angular-material and mdi into my working folder. npm install angular-material mdi errors with:

+-- angular@1.5.0

+-- UNMET PEER DEPENDENCY angular-animate@^1.5.0

+-- UNMET PEER DEPENDENCY angular-aria@^1.5.0

+-- angular-material@1.0.6

+-- UNMET PEER DEPENDENCY angular-messages@^1.5.0 `-- mdi@1.4.57

npm WARN enoent ENOENT: no such file or directory, open
'C:\Users\xxxxx\Desktop\ngClassifieds\package.json' 

npm WARN angular-material@1.0.6 requires a peer of
angular-animate@^1.5.0 but none was installed. 

npm WARN angular-material@1.0.6 requires a peer of angular-aria@^1.5.0
but none was installed. 

npm WARN angular-material@1.0.6 requires a peer of
angular-messages@^1.5.0 but none was installed.

How do I resolve this to get AngularJS Material and MDI installed?


Solution

npm no longer installs peer dependencies so you need to install them manually, just do an npm install on the needed deps, and then try to install the main one again.


Reply to comment:

it's right in that message, it says which deps you're missing

UNMET PEER DEPENDENCY angular-animate@^1.5.0 +-- 
UNMET PEER DEPENDENCY angular-aria@^1.5.0 +-- angular-material@1.0.6 +
UNMET PEER DEPENDENCY angular-messages@^1.5.0 `-- mdi@1.4.57` 

So you need to npm install angular angular-animate angular-aria angular-material angular-messages mdi



Answered By - Datsik
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, October 9, 2022

[FIXED] What is the difference between "npm install" and "npm ci"?

 October 09, 2022     continuous-integration, npm, npm-ci, npm-install     No comments   

Issue

I'm working with continuous integration and discovered the npm ci command.

I can't figure what the advantages are of using this command for my workflow.

Is it faster? Does it make the test harder, okay, and after?


Solution

From the official documentation for npm ci:

In short, the main differences between using npm install and npm ci are:

  • The project must have an existing package-lock.json or npm-shrinkwrap.json.
  • If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
  • npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
  • If a node_modules is already present, it will be automatically removed before npm ci begins its install.
  • It will never write to package.json or any of the package-locks: installs are essentially frozen.

Essentially, npm install reads package.json to create a list of dependencies and uses package-lock.json to inform which versions of these dependencies to install. If a dependency is not in package-lock.json it will be added by npm install.

npm ci (also known as Clean Install) is meant to be used in automated environments — such as test platforms, continuous integration, and deployment — or, any situation where you want to make sure you're doing a clean install of your dependencies.

It installs dependencies directly from package-lock.json and uses package.json only to validate that there are no mismatched versions. If any dependencies are missing or have incompatible versions, it will throw an error.

Use npm install to add new dependencies, and to update dependencies on a project. Usually, you would use it during development after pulling changes that update the list of dependencies but it may be a good idea to use npm ci in this case.

Use npm ci if you need a deterministic, repeatable build. For example during continuous integration, automated jobs, etc. and when installing dependencies for the first time, instead of npm install.

npm install

  • Installs a package and all its dependencies.
  • Dependencies are driven by npm-shrinkwrap.json and package-lock.json (in that order).
  • without arguments: installs dependencies of a local module.
  • Can install global packages.
  • Will install any missing dependencies in node_modules.
  • It may write to package.json or package-lock.json.
    • When used with an argument (npm i packagename) it may write to package.json to add or update the dependency.
    • when used without arguments, (npm i) it may write to package-lock.json to lock down the version of some dependencies if they are not already in this file.

npm ci

  • Requires at least npm v5.7.1.
  • Requires package-lock.json or npm-shrinkwrap.json to be present.
  • Throws an error if dependencies from these two files don't match package.json.
  • Removes node_modules and install all dependencies at once.
  • It never writes to package.json or package-lock.json.

Algorithm

While npm ci generates the entire dependency tree from package-lock.json or npm-shrinkwrap.json, npm install updates the contents of node_modules using the following algorithm (source):

load the existing node_modules tree from disk
clone the tree
fetch the package.json and assorted metadata and add it to the clone
walk the clone and add any missing dependencies
  dependencies will be added as close to the top as is possible
  without breaking any other modules
compare the original tree with the cloned tree and make a list of
actions to take to convert one to the other
execute all of the actions, deepest first
  kinds of actions are install, update, remove and move


Answered By - lucascaro
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, September 27, 2022

[FIXED] Why is Kudu node version not updating after setting is applied?

 September 27, 2022     azure, continuous-deployment, kudu, npm, npm-install     No comments   

Issue

I've been trying to deploy an Angular Application to Azure App Service, the deploy fails and it gives the following log:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
  Restore completed in 862 ms for D:\home\site\repository\src\Bearbersys.ui\Bearbersys.ui.csproj.
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 418.94 ms for D:\home\site\repository\src\Bearbersys.ui\Bearbersys.ui.csproj.
  Bearbersys.ui -> D:\home\site\repository\src\Bearbersys.ui\bin\Release\netcoreapp2.2\Bearbersys.ui.dll
  Bearbersys.ui -> D:\home\site\repository\src\Bearbersys.ui\bin\Release\netcoreapp2.2\Bearbersys.ui.Views.dll
EXEC : npm ERR! error : Method Not Allowed [D:\home\site\repository\src\Bearbersys.ui\Bearbersys.ui.csproj]
  npm ERR!     at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)
  npm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12
  npm ERR!     at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)
  npm ERR!     at Object.oncomplete (fs.js:108:15)
  npm ERR! If you need help, you may report this *entire* log,
  npm ERR! including the npm and node versions, at:
  npm ERR!     <http://github.com/npm/npm/issues>

  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "node" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install"
  npm ERR! cwd D:\home\site\repository\src\Bearbersys.ui\ClientApp
  npm ERR! node -v v0.10.40
  npm ERR! npm -v 1.4.28
  npm ERR! code E405
D:\home\site\repository\src\Bearbersys.ui\Bearbersys.ui.csproj(39,5): error MSB3073: The command "npm install" exited with code 1.
Failed exitCode=1, command=dotnet publish "D:\home\site\repository\src\Bearbersys.ui\Bearbersys.ui.csproj" --output "D:\local\Temp\8d6e13963485ed1" --configuration Release
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\81.10329.3844\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

After some research I've found that this has something to do with the node package in my App Service, thus I've tried to add the following Application Setting to it:

[
  {
    "name": "WEBSITE_NODE_DEFAULT_VERSION",
    "value": "10.15.3",
    "slotSetting": false
  }
]

10.15.3 is the current node version and the same version installed in my computer when I created the Angular App, even though the setting is succefully applied the error persists after redeploying. I've also noticed that the node version showed by the log hasn't changed.

  npm ERR! node -v v0.10.40
  npm ERR! npm -v 1.4.28

What am I possibly doing wrong?


Solution

For nodejs release schedule, please refer to: https://github.com/nodejs/Release

Find current nodejs versions available in Azure Windows WebApps, navigate to this link:

https://<yourwebappname>.scm.azurewebsites.net/api/diagnostics/runtime

You can only use the versions available in this list.

New versions are added regularly, so please check for newer versions using the /api/diagnostics/runtime url above.

enter image description here



Answered By - George Chen
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, August 24, 2022

[FIXED] How to use npm modules in browser? is possible to use them even in local (PC)?

 August 24, 2022     javascript, module, node.js, npm, npm-install     No comments   

Issue

I'm new to npm module and node.js so it is really difficult to me.

I have a js code whit many points and for each one of them I want to get the nearest city.

To do this, in other question (Reverse geocoding with big array is fastest way? - javascript and performance), a user suggested me to use two npm modules,

const kdbush = require('kdbush');
const geokdbush = require('geokdbush');

// I've stored the data points as objects to make the values unambiguous
const cities = [
  { name: "Abano Terme (PD)", latitude: 45.3594, longitude: 11.7894 },
  { name: "Abbadia Cerreto (LO)", latitude: 45.3122, longitude: 9.5928 },
  { name: "Abbadia Lariana (LC)", latitude: 45.8992, longitude: 9.3336 },
  { name: "Abbadia San Salvatore (SI)", latitude: 42.8800, longitude: 11.6775 },
  { name: "Abbasanta (OR)", latitude: 40.1250, longitude: 8.8200 }
];

// Create the index over city data ONCE
const index = kdbush(cities, ({ longitude }) => longitude, ({ latitude }) => latitude);

// Get the nearest neighbour in a radius of 50km for a point with latitude 43.7051 and longitude 11.4363
const nearest = geokdbush.around(index, 11.4363, 43.7051, 1, 50);

The problem is this is the first time that I approach at this. Besides I'm Italian and don't speak English very well, and in Italian Google there's nothing.

Can you tell me how could I use these modules?

Do I have to install Node.js on my server?

Is it possible to use modules on local PC?


Solution

browserify is the correct direction, but it took me quite some effort to work out the actual solution. I have summarized a short blog for this, and here are some quick recap:

Say, you want to use emailjs-mime-parser and buffer npm libraries in your HTML.

  1. install everything required
npm install -g browserify
npm install emailjs-mime-parser
npm install buffer
  1. write a simple main.js as a wrapper:
var parse = require('emailjs-mime-parser').default
var Buffer = require('buffer').Buffer
global.window.parseEmail = parse
global.window.Buffer = Buffer
  1. compile everything using browserify
browserify main.js -o bundle.js
  1. now, you could use bundle.js inside the HTML file.
<html>
<head>
<script src='bundle.js'></script>
<script>
console.log(window.parseEmail);
console.log(window.Buffer);
</script>
<body>
</body>
</html>


Answered By - Walty Yeung
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, August 22, 2022

[FIXED] How do I fix the npm error EACCES: permission denied?

 August 22, 2022     environment-variables, linux, npm, npm-install, path     No comments   

Issue

I tried to start a project with installing npm install -g pnpm as a requirement and I tried npm install but it does work. But npm install -g pnpmshows errors as follow; Below is from the terminal!

npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/pnpm/bin/pnpm.cjs
npm ERR! dest /usr/bin/pnpm
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'
npm ERR!  [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'] {
npm ERR!   cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'symlink',
npm ERR!     path: '../lib/node_modules/pnpm/bin/pnpm.cjs',
npm ERR!     dest: '/usr/bin/pnpm'
npm ERR!   },
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/pnpm/bin/pnpm.cjs',
npm ERR!   dest: '/usr/bin/pnpm'
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.

Solution

  1. Back up your computer.

  2. On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global
  1. Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
  1. In your preferred text editor, open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH

  1. On the command line, update your system variables:
source ~/.profile

  1. To test your new configuration, install a package globally without using sudo:
npm install -g pnpm

source : https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally



Answered By - Javad
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing