I want to update multiple npm dependecies and save them to the respective package.json dependency slot.
My package.json:
{
"dependencies": {
"gulp": "^3.0.0"
},
"devDependencies": {
"gulp-eslint": "^2.8.0"
}
}
So i want to run:
$ npm update gulp gulp-eslint
That's ok but how to save the newer versions both for gulp (dep) and gulp-eslint (devDep) respectively ?
I tried:
$ npm update gulp gulp-eslint --save
but gulp-eslint is devDependency actually must be saved there, how to do all this in 1 command line?
You can check the official documentation for npm-update and notice that there are different specifications according to the npm version you are using.
From the command line you can do:
$ npm update --save --dev
Note: Use sudo if your are on Linux or Mac.
You can also use Yarn, which is a new package manager, with this command:
yarn upgrade
https://yarnpkg.com/en/docs/cli/upgrade
Related
i have " cannot find module '#babel/generator' " error while trying generate signed apk.
But i installed this package using yarn add, this is part of my package.json:
"dependencies": {
"#babel/cli": "^7.17.6",
"#babel/generator": "^7.17.9",
"#babel/plugin-transform-async-to-generator": "^7.16.8",
and my package lock json:
"dependencies": {
"#ampproject/remapping": "^2.1.0",
"#babel/code-frame": "^7.16.7",
"#babel/generator": "^7.17.9",
and many match when i use ctrl+f in package.lock.json and search babel/generator
I received the same error when i was trying to install the dependencies of my project.
Solution:
Delete the node_modules folder of the project
Remove the yarn.lock or package.lock file from your project
Install the dependencies again, by using yarn or npm install command.
The above steps fixed my error with the #babel/generator.
Simply delete the node_modules folder and re-install all the packages by running npm install or yarn install.
If the error persists, simply install the #babel/generator package to your project or globally.
Check out the package and installation guide here
in my case it solved by this command
yarn install --check-files
and then restart the dev server
Verifies that already installed files in node_modules did not get removed
Good luck
I literally just made a fresh installation of the Angular CLI in order to try it out and I don't have a clue on what's causing the following error on the command line:
PC:cobros Fran$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
95% emitting/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40
callbacks[i](err, result);
^
TypeError: callbacks[i] is not a function
at Storage.finished (/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40:15)
at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:77:9
at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/graceful-fs/polyfills.js:287:18
at FSReqWrap.oncomplete (fs.js:153:5)
This is the information I get returned when I try "ng -v" (In case it's useful at all):
Angular CLI: 1.6.8
Node: 8.9.0
OS: darwin x64
Angular: 5.2.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
#angular/cli: 1.6.8
#angular-devkit/build-optimizer: 0.0.42
#angular-devkit/core: 0.0.29
#angular-devkit/schematics: 0.0.52
#ngtools/json-schema: 1.1.0
#ngtools/webpack: 1.9.8
#schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
What does the 'enhanced-resolve' module even do?
Did I install angular wrong? I followed the instructions from https://github.com/angular/angular-cli and made sure I fulfilled the prerequisites.
EDIT: The issue is now fixed, so there is no need to use this workaround anymore.
Solution (workaround) found here
Add "copy-webpack-plugin": "4.3.0" to your package.json
Thanks #neshkatrapati
I had same problem and this command did miracle for me
npm install copy-webpack-plugin#4.3.1
This issue should now be resolved with v4.4.1 released just now.
https://github.com/webpack-contrib/copy-webpack-plugin/releases/tag/v4.4.1
EDIT: The issue is now fixed, so there is no need to use this workaround anymore.
Happens after upgrading #angular/cli to 1.6.8.
Solution: Problem is with copy-webpack-plugin (https://github.com/webpack-contrib/copy-webpack-plugin/issues/217)
npm i copy-webpack-plugin#4.3.1 --save-dev helps
NOTE: Previous offered solution was to downgrade cli to 1.6.7, which does not help.
As stated here https://github.com/angular/angular-cli/issues/9550 it's a problem with copy-webpack-plugin.
It can be solved by doing npm install copy-webpack-plugin#4.3.0
Following github.com/angular/angular-cli/issues/9550 (thanks #oers for the link in the comments)
I just downgraded Anuglar CLI to version 1.6.7.
To do so, just type
npm uninstall -g #angular/cli
And once it finished install a previous version
npm install -g #angular/cli#1.6.7
NOTE: This will work but it is just a temporary solution, they probably -and hopefully- hot fix this.
EDIT: Actually I tried the wrong project which wasn't using CLI, tried again and it doesn't work, if you follow the github thread, it looks like a big thing, as it doesn't work with CLI 1.5.x nor 1.6.x (didn't tried with the others). It looks like the only thing we can do ATM is either debug through or sit and wait.
OOPS!
if npm install copy-webpack-plugin#4.3.1 doesn`t help try add in package.json:
"optionalDependencies": {
"copy-webpack-plugin": "4.3.1"
},
"resolutions": {
"copy-webpack-plugin": "4.3.1"
}
Edit
Just execute yarn upgrade.
There was a release of copy_webpack_plugin fixing the bug (4.4.1), so this should be preferred for resolving this issue. With npm, npm --depth 9999 update should do the trick to update all dependencies recursively.
Regarding the depth argument for npm update:
As of npm#2.6.1, the npm update will only inspect top-level packages. Prior versions of npm would also recursively inspect all dependencies. To get the old behavior, use npm --depth 9999 update
Original answer below:
Solution
rm -rf node_modules package-lock.json
npm i copy-webpack-plugin#4.3.1 -E -O
npm i
Explanation:
We remove node_modules and lockfile
We specify copy_webpack_plugin only as a peer dependency (option -O) and with an exact version (option -E)
We install node_modules
Try this command -> npm install copy-webpack-plugin#4.3.0 resolved my issue
run this command npm install copy-webpack-plugin#4.3.0
callbacks[i](err, result);
^
TypeError: callbacks[i] is not a function
solution:-
npm install copy-webpack-plugin#4.3.0
Try to uninstall and reinstall Angular CLI :
Global package:
npm uninstall -g #angular/cli
npm cache clean
if npm version is > 5 then usenpm cache verifyto avoid errors (or to avoid using --force)
npm install -g #angular/cli#latest
Local project package:
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev #angular/cli#latest
npm install
I have created a angular project with Angular CLI: 1.6.3 Node: 9.4.0
OS: linux x64 version. But when want to run my angular app with command ng serve then fetch this error
Cannot find module '#angular-devkit/core'.
Try the following steps,
Step 1:
npm update -g #angular/cli
Step 2:
Edit your package.json changing the line
"#angular/cli": "1.6.0",
to
"#angular/cli": "^1.6.0",
STEP 3:
npm update
Refer the steps
try this out
npm install #angular-devkit/core --save-dev
https://github.com/angular/devkit/issues/256
try to update your angular cli
https://github.com/angular/angular-cli/issues/9307
Step1: Edit your package.json changing the line
#angular/cli": "1.6.4"
to
#angular/cli": "^1.6.4"
Step2:
npm update -g #angular/cli
Step3:
npm install --save-dev #angular/cli#latest
I was facing the exact same problem. These three did the tasks for me. You may like to see https://github.com/angular/angular-cli/issues/9307
This can happen on different versions on angular-cli.
You can install it manually with
npm i -D #angular-devkit/core
-D is shortcut to --save-dev
Or try the latest version of angular cli
npm install --save-dev #angular/cli#latest
package.json, change to "#angular/cli": "^1.6.5",
"devDependencies": {
"#angular/cli": "^1.6.5",
"#angular/compiler-cli": "^5.0.0",
Important, the version could be vary depends on what time.
You really should run
npm update -g #angular/cli
first, to get version, my is 1.6.5
What does the "^" do?
~1.0.2 means to install version 1.0.2 or the latest patch version such as 1.0.4.
^1.0.2 means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.
last, run this
npm update
Just run:
npm install --save-dev #angular/cli#latest
In the project folder, to fix it.
I did it by deleting package-lock.json and the node_modules folder. After that run "npm install" and start the application again.
You can do
First,
Delete the node_modules folder
Run npm install
And add devkit to your dev dependancies with npm i -D #angular-devkit/core
Step 1: delete package-lock.json
Step 2: npm update -g #angular/cli
Step 3: update #angular/cli new version in package.json
Step 4: npm install
It worked for me.
I only installed my angular/cli using:
npm install -g #angular/cli#1.5.2
And I started getting this error.
Solution:
If your version is global and
If you don't mind the version of your angular/cli then type:
npm update -g #angular/cli
for me adding #angular-devkit/core solved the issue
npm install --save-dev #angular-devkit/core
I had this same error after updating some packages.
In my package.json I had the most current '#angular-devkit/core'
Using the standard solution to many problems:
rm -R node_modules/
npm install
And I updated the #angular/cli
npm install --save-dev #angular/cli#latest
and finally:
npm start
Only change "#angular/cli": "1.6.4", to "#angular/cli": "^1.6.4", and update npm with: npm update
I have a workspace on c9.io, and I am using node.js. I am trying to update socket.io from 0.9.17 to the latest version. However, whenever I run the command npm update socket.io it installs the same version. How can I fix this?
To install the latest available package:
npm install <package>
To install a version directly (no need to uninstall first):
npm install <package>#<version>
If you're not sure what versions of a package are available, you can use:
npm view <package> versions
Don't forget the --save flag to add dependencies to your package.json file.
Source: How do I install a previous version of an npm package?
About npm update
However, if app's package.json contains:
"dependencies": {
"dep1": "~1.1.1"
}
In this case, running npm update will install dep1#1.1.2. Even though the latest tag points to 1.2.2, this version does not satisfy ~1.1.1, which is equivalent to >=1.1.1 <1.2.0. So the highest-sorting version that satisfies ~1.1.1 is used, which is 1.1.2.
Source: npm update - Tilde Dependencies
After installing gulp.js via npm, I receive a no command 'gulp' found error when running the gulp command from the same directory it was installed into.
When looking under the node_modules/.bin/ directory, I can see the gulp executable there.
Is there something wrong with my npm installation?
That's perfectly normal.
If you want gulp-cli available on the command line, you need to install it globally.
npm install --global gulp-cli
See the install instruction.
Also, node_modules/.bin/ isn't in your $PATH. But it is automatically added by npm when running npm scripts (see this blog post for reference).
So you could add scripts to your package.json file:
{
"name": "your-app",
"version": "0.0.1",
"scripts": {
"gulp": "gulp",
"minify": "gulp minify"
}
}
You could then run npm run gulp or npm run minify to launch gulp tasks.
I solved the issue without reinstalling node using the commands below:
$ npm uninstall --global gulp gulp-cli
$ rm /usr/local/share/man/man1/gulp.1
$ npm install --global gulp-cli
I actually have the same issue.
This link is probably my best guess:
nodejs vs node on ubuntu 12.04
I did that to resolve my problem:
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
I solved the issue removing gulp and installing gulp-cli again:
rm /usr/local/bin/gulp
npm install -g gulp-cli
if still not resolved try adding this to your package.js scripts
"scripts": { "gulp": "gulp" },
and run npm run gulp
it will runt gulp scripts from gulpfile.js
Installing on a Mac - Sierra - After numerous failed attempts to install and run gulp globally via the command line using several different instructions I found I added this to my path and it worked:
export PATH=/usr/local/Cellar/node/7.6.0/libexec/npm/bin/:$PATH
I got that path from the text output when installing gulp.
Tried with sudo and it worked !!
sudo npm install --global gulp-cli
I'm on lubuntu 19.10
I've used combination of previous answers, and didn't tweak the $PATH.
npm uninstall --global gulp gulp-cli
This removes any package if they are already there.
sudo npm install --global gulp-cli Reinstall it as root user.
If you want to do copy and paste
npm uninstall --global gulp gulp-cli && sudo npm install --global gulp-cli
should work
I guess --global is unnecessary here as it's installed using sudo, but I've used it just in case.
in my case there was only on issue, just put "gulp":"gulp" in the script portion, of package.json, and then use command npm run gulp.