How to update ember packages? - node.js

I have my old project that use Ember 2.8.
Now, I want to update all the packages and here is the updated package.json
{
"name": "php-api-ember-test",
"version": "0.0.0",
"description": "Small description for php-api-ember-test goes here",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"repository": "",
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~2.14.2",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.3.0",
"ember-cli-bootstrap-4": "^0.3.2",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-eslint": "^3.0.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^1.0.0",
"ember-cli-qunit": "^4.1.0",
"ember-cli-release": "^0.2.9",
"ember-cli-sass": "5.5.1",
"ember-cli-sri": "^2.1.0",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "~2.14.9",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-welcome-page": "^3.0.0",
"loader.js": "^4.2.3"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
},
"private": true
}
And this is bower.json
{
"name": "php-api-ember-test",
"dependencies": {
"ember": "~2.14.0",
"ember-cli-shims": "0.1.1"
}
}
I was deleted the bower_components and node_modules folders and then run the command npm install && bower install.
After those install completed I run ember init and get this result.
Missing npm packages:
Package: ember-ajax
* Specified: ^3.0.0
* Installed: 2.5.6
Package: ember-cli-app-version
* Specified: ^3.0.0
* Installed: 1.0.1
Package: ember-cli-babel
* Specified: ^6.3.0
* Installed: 5.2.4
Package: ember-cli-htmlbars
* Specified: ^2.0.1
* Installed: 1.3.4
Package: ember-cli-htmlbars-inline-precompile
* Specified: ^0.4.3
* Installed: 0.3.13
Package: ember-cli-qunit
* Specified: ^4.1.0
* Installed: 2.2.6
Package: ember-export-application-global
* Specified: ^2.0.0
* Installed: 1.1.1
Package: ember-load-initializers
* Specified: ^1.0.0
* Installed: 0.5.1
Package: ember-resolver
* Specified: ^4.0.0
* Installed: 2.1.1
Package: ember-welcome-page
* Specified: ^3.0.0
* Installed: 1.0.4
Run `npm install` to install missing dependencies.
An error occured in the constructor for ember-cli-dependency-checker
But I'm already run the npm install commands for many times.
How to update Ember packages?

The official upgrade docs are here: ember-cli upgrade. Details are in release notes.
First of all, there are some distinct steps:
Setting up the global ember-cli
Upgrading the project ember version
Upgrading the all other addons
You should better to do them step-by-step.
By the way, look all the release notes of the releases you've passed through. Because there may some differences. For example, for older versions (2.14, 2.13..) there were bower cache clean and bower install steps. For new versions (2.15), those steps are not necessary.

Don't use npm. Use yarn. It's faster, more secure and has better cache. It's also recommended as migration path from Bower (by Bower). Yarn is also recommended by Ember team instead of npm.
rm -rf node_modules
yarn

Use yarn to selective package update
yarn upgrade-interactive --latest

Related

NPM doesn't install dependencies that need build

My package.json file looks like the following :
{
"name": "anna-backend",
"version": "1.0.3",
"description": "Backend for ANNA intranet",
"main": "app.js",
"author": "IpsaOne DevTeam",
"private": true,
"license": "ISC",
"dependencies": {
"async": "^2.6.0",
"bcrypt": "^1.0.3",
"body-parser": "^1.17.2",
"mmmagic": "^0.4.6",
[...]
}
}
When I run npm install in the folder, everything installs well except the dependencies that require building via node-gyp (like bcrypt, mmmagic) and I have to install them manually by typing npm install mmmagic. Otherwise, they're just not installed and my application doesn't start.
Is it expected behaviour ? Can I do anything about it ?
mmmagic module has issues on install
https://github.com/mscdex/mmmagic/issues/111
try install at last version 0.5.0

Only install packages that are included in the package.json

I just want to install only packages that are included in the packages.json. But when I run npm install, over 800 packages are suddenly installed. Is there a specific command to realize this or is my package.json (see below) wrong?
{
"name": "test",
"version": "1.0.0",
"description": "test",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "test",
"license": "ISC",
"devDependencies": {
"browser-sync": "^2.13.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^5.0.0",
"gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.2",
"gulp-htmlmin": "^4.0.0",
"gulp-imagemin": "^4.1.0",
"gulp-install": "^1.1.0",
"gulp-jade": "^1.1.0",
"gulp-jsonminify": "^1.0.0",
"gulp-ng-annotate": "^2.0.0",
"gulp-sass": "^4.0.1",
"gulp-uglify": "^3.0.0"
},
"dependencies": {
"critical": "^1.2.2",
"imagemin-pngquant": "^5.0.0"
}
}
npm install uses package.json to install packages you want AND their own dependencies. So you haven't choice unless you want broken packages ? In that case you could manually uninstall packages you don't want.
In this case when u install this packages the dependencies of that particular packages has also been installed.
Like if u install critical module then =>
bluebird
chalk
cheerio
clean-css
cli
debug
filter-css
fs-extra ... etc
has also been installed, that's the case in here
I am not sure why would that be happening, whenever we run npm install it picks up the package.json and installs packages defined in it including the transitive dependencies. By looking at your package.json there should not be 800 of them.unless you have multiple package.json linked up with each other.
I would recommend to copy package.json to a different directory and clear cached in modules and
run npm install --log-level=verbose
this should give in the details for the rest packages being called up.

How to solve npm install throwing fsevents warning on non-MAC OS?

Following warning is being thrown on npm install command -
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.2 (node_modules\rea
ct-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\ch
okidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
The warning is apparently causing our Jenkins Job to mark failed, so we are just trying to get rid of the same.
I already checked this https://stackoverflow.com/a/42938398/351903
But, unlike what is mentioned there, I do not have any /node_modules/fserrors in my setup. Also, my package.json does not contain fserrors. Following is my package.json -
{
"name": "mvc-panel",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
"jquery": "^3.2.1",
"material-ui": "^0.18.3",
"qs": "^6.4.0",
"react": "^15.5.4",
"react-alert": "^2.1.2",
"react-bootstrap-table": "^3.4.1",
"react-dom": "^15.5.4",
"react-loader": "^2.4.2",
"react-router-dom": "^4.1.1",
"react-tap-event-plugin": "^2.0.1",
"serve": "^6.0.0"
},
"devDependencies": {
"datatables.net": "^1.10.15",
"jquery": "^3.2.1",
"react-scripts": "^1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I can see fsevents in the package.json of react-scripts (which is defined under devDependencies of my package.json) in node_modules\react-scripts\package.json -
{
"_args": [
[
{
"raw": "react-scripts#^1.0.7",
"scope": null,
"escapedName": "react-scripts",
"name": "react-scripts",
"rawSpec": "^1.0.7",
"spec": ">=1.0.7 <2.0.0",
"type": "range"
},
"D:\\Sandeepan\\Payu MVC\\backend codebase\\MVC2.0\\panel\\mvc-panel"
]
],
"_from": "react-scripts#>=1.0.7 <2.0.0",
"_id": "react-scripts#1.0.14",
"_inCache": true,
"_location": "/react-scripts",
"_nodeVersion": "8.5.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/react-scripts-1.0.14.tgz_1506471610836_0.5613740666303784"
},
"_npmUser": {
"name": "timer",
"email": "timer150#gmail.com"
},
"_npmVersion": "5.3.0",
"_phantomChildren": {
"asap": "2.0.6",
"escape-string-regexp": "1.0.5",
"graceful-fs": "4.1.11",
"has-ansi": "2.0.0",
"universalify": "0.1.1"
},
"_requested": {
"raw": "react-scripts#^1.0.7",
"scope": null,
"escapedName": "react-scripts",
"name": "react-scripts",
"rawSpec": "^1.0.7",
"spec": ">=1.0.7 <2.0.0",
"type": "range"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.14.tgz",
"_shasum": "70fe76c9beb67b136b953e875bdfe4ad78d410d1",
"_shrinkwrap": null,
"_spec": "react-scripts#^1.0.7",
"_where": "D:\\Sandeepan\\Payu MVC\\backend codebase\\MVC2.0\\panel\\mvc-panel",
"bin": {
"react-scripts": "./bin/react-scripts.js"
},
"bugs": {
"url": "https://github.com/facebookincubator/create-react-app/issues"
},
"dependencies": {
"autoprefixer": "7.1.2",
"babel-core": "6.25.0",
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.1.1",
"babel-preset-react-app": "^3.0.3",
"babel-runtime": "6.26.0",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"css-loader": "0.28.4",
"dotenv": "4.0.0",
"eslint": "4.4.1",
"eslint-config-react-app": "^2.0.1",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.35.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.1.0",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "0.11.2",
"fs-extra": "3.0.1",
"fsevents": "1.1.2",
"html-webpack-plugin": "2.29.0",
"jest": "20.0.4",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.6",
"promise": "8.0.1",
"react-dev-utils": "^4.1.0",
"style-loader": "0.18.2",
"sw-precache-webpack-plugin": "0.11.4",
"url-loader": "0.5.9",
"webpack": "3.5.1",
"webpack-dev-server": "2.8.2",
"webpack-manifest-plugin": "1.2.1",
"whatwg-fetch": "2.0.3"
},
"description": "Configuration and scripts for Create React App.",
"devDependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"directories": {},
"dist": {
"integrity": "sha512-+p0q2N2WW7L4WW6uObqN7fYwSQZ9fBI0StpMYl1Ukoz/lCbemf+yW6b8refyhTsGy62GAqxlpyEfVcTE3hJAxg==",
"shasum": "70fe76c9beb67b136b953e875bdfe4ad78d410d1",
"tarball": "https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.14.tgz"
},
"engines": {
"node": ">=6"
},
"files": [
"bin",
"config",
"scripts",
"template",
"utils"
],
"homepage": "https://github.com/facebookincubator/create-react-app#readme",
"license": "MIT",
"maintainers": [
{
"name": "timer",
"email": "timer150#gmail.com"
},
{
"name": "fb",
"email": "opensource+npm#fb.com"
},
{
"name": "gaearon",
"email": "dan.abramov#gmail.com"
}
],
"name": "react-scripts",
"optionalDependencies": {
"fsevents": "1.1.2"
},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/facebookincubator/create-react-app.git"
},
"version": "1.0.14"
}
Update
I tried running the npm install command and getting the exit status of the earlier command. It showed 0 meaning success, despite the warnings. So, it does not look like Jenkins job should be stuck due to this. However, we are still trying to find a way to get rid of this warning because it is not relevant to our OS.
fsevents is dealt differently in mac and other linux system. Linux system ignores fsevents whereas mac install it. As the above error message states that fsevents is optional and it is skipped in installation process.
You can run npm install --no-optional command in linux system to avoid above warning.
Further information
https://github.com/npm/npm/issues/14185
https://github.com/npm/npm/issues/5095
If you want to hide this warn, you just need to install fsevents as a optional dependency.
Just execute:
npm i fsevents#latest -f --save-optional
..And the warn will no longer be a bother.
npm i -f
I'd like to repost some comments from this thread, where you can read up on the issue and the issue was solved.
This is exactly Angular's issue. Current package.json requires fsevent
as not optionalDependencies but devDependencies. This may be a problem
for non-OSX users.
Sometimes
Even if you remove it from package.json npm i still fails because
another module has it as a peer dep.
So
if npm-shrinkwrap.json is still there, please remove it or try npm i
-f
package.json counts with a optionalDependencies key.
NPM on Optional Dependencies.
You can add fsevents to this object and if you find yourself installing packages in a different platform than MacOS, fsevents will be skipped by either yarn or npm.
"optionalDependencies": {
"fsevents": "2.1.2"
},
You will find a message like the following in the installation log:
info fsevents#1.2.11: The platform "linux" is incompatible with this module.
info "fsevents#1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents#2.1.2: The platform "linux" is incompatible with this module.
info "fsevents#2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
Hope it helps!
I found the same problem and i tried all the solution mentioned above and in github. Some works only in local repository, when i push my PR in remote repositories with travic-CI or Pipelines give me the same error back. Finally i fixed it by using the npm command below.
npm audit fix --force
This no longer happens with npm v7. You can update your npm version or update to node v15 or higher, which by default installs npm v7.
Follow these steps -
Go to the project's "package.lock.json" file
Press "Ctrl+F" (to enable search)
Type "darwin"
Rename it to 'linux'
I also had the same issue though am using MacOS. The issue is kind of bug. I solved this issue by repeatedly running the commands,
sudo npm cache clean --force
sudo npm uninstall
sudo npm install
One time it did not work but when I repeatedly cleaned the cache and after uninstalling npm, reinstalling npm, the error went off. I am using Angular 8 and this issue is common
Instead of using --no-optional every single time, we can just add it to npm or yarn config.
For Yarn, there is a default no-optional config, so we can just edit that:
yarn config set ignore-optional true
For npm, there is no default config set, so we can create one:
npm config set ignore-optional true
Do this:
npm install --no-optional
For more info on this go through: https://github.com/npm/npm/issues/11632
I'm using,
Angular CLI: 8.1.2
Node: 12.14.1
OS: win32 x64
Strangely, this helped me
npm cache clean --force
npm uninstall #angular/cli
npm install #angular/cli#8.1.2
For anyone reading it recently, the simplest thing to do on Ubuntu is to install the latest LTS versions of nvm, node.js, and nmp. from version 7 of node.js, these issues have been sorted out.
Refer to this guide:
https://computingforgeeks.com/how-to-install-node-js-on-ubuntu-debian/
I solved this by deleting the node_modules folder and running npm i.
I got the same error. In my case, I was using a mapped drive to edit code off of a second computer, that computer was running linux. Not sure exactly why gulp-watch relies on operating system compatibility prior to install (I would assume it has to do with security purposes). Essentially the error is checking against your operating system and the operating system calling the node module, in my case the two operating systems were not the same so it threw it error. Which from the looks of your error is the same as mine.
The Error
Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
How I fixed it?
I logged into the linux computer directly and ran
npm install --save-dev <module-name>
Then went back into my coding environment and everything was fine after that.
Hope that helps!
run
npm install -D vue-loader vue-template-compiler
Vue CLI
If you are not interested in manually setting up webpack, it is recommended to scaffold a project with Vue CLI instead. Projects created by Vue CLI are pre-configured with most of the common development needs working out of the box.
Follow this guide if the built-in configuration of Vue CLI does not suit your needs, or you'd rather create your own webpack config from scratch.
#Manual Setup
#Installation
Unless you are an advanced user using your own forked version of Vue's template compiler, you should install vue-loader and vue-template-compiler together:
Check your node version and check if the package.json was generate using a different version of node.
I downloaded a repo created from Mac from a Linux and faced this error when trying to npm install. I was using node v14.15.0 and when I switched to v16.13.0, the error disappeared.
Yes, it works when with the command npm install --no-optional
Using environment:
iTerm2
macos login to my vm ubuntu16 LTS.
I had got this error, Linux system(Ubuntu) and This might happen when you run :
npm install
1) If the project is not present in your localdisk/computer, copy it to your computer and try again. So you get the permission to access folder (Just make sure you have access permission).
2) If you still get some warnings or errors, run:
npm audit fix
This will solve vulnerabilities in your dependencies and can help you fix a vulnerability by providing simple-to-run npm commands and recommendations for further troubleshooting.
Hope it helps!
Switch to PNPM: https://pnpm.js.org/
The fsevents warnings are gone (on Linux).
Even the latest yarn (2.x) shows the warnings.
If anyone get this error for ionic cordova install . just use this code npm install --no-optional in your cmd.
And then run this code npm install -g ionic#latest cordova
Use sudo npm install -g appium.

how to download and install all node modules through package.json?

I want to invoke and download all node modules through maven, in maven I have defined the plugins to install it but now in my package.json i have defined the following npm install command, please advise how can i install all node modules and can define them in package.json
package.json
{
"name": "MyProject",
"version": "1.0.0",
"author": "Saral",
"scripts":{
"start":"node gulpfile.js",
"prebuild": "npm install",
"build": "gulp"
},
"dependencies": {
"gulp": "*",
"gulp-ruby-sass": "*",
"gulp-util": "*",
"gulp-rename": "*",
"gulp-concat": "^2.6.0",
"gulp-concat-vendor": "0.0.4",
"map-stream": "*",
"gulp-livereload": "*",
"gulp-concat": "*",
"gulp-uglify": "*",
"gulp-minify-css" : "^1.2.1",
"gulp-notify":"2.2.0",
"gulp-inject": "1.5.0",
"run-sequence": "1.1.4",
"stream-series": "0.1.1",
"gulp-gzip": "1.2.0",
"gulp-clone": "1.0.0",
"gulp-watch": "*"
}
}
Go to your terminal and type in
npm install
This will crawl through all the required packages mentioned in package.json and download it to node_modules folder.
When using gulp in your gulpfile.js
var install = require("gulp-install");
gulp.src(['./bower.json', './package.json'])
.pipe(install());
So when you run gulp in your terminal all the packages in bower.json and package.json will be downloaded into bower_components and node_modules, respectively.
As I understand the question, just use the "Frontend Maven Plugin"
It installs node & npm: https://github.com/eirslett/frontend-maven-plugin#installing-node-and-npm
Executes npm install, which is already the default argument and can be omitted: https://github.com/eirslett/frontend-maven-plugin#running-npm

Conditionally Include Dependency package.json

I have a dependency that is only needed for Mac OS in an npm project and was wondering if there is some way to conditionally include this dependency only when the compatible platform is the one running npm install.
I'm willing to write the logic for this. In the below case grunt-appdmg is causing the npm install process to error out (for fairly obvious reasons) with:
'/dev/cuttle/node_modules/grunt-appdmg/node_modules/appdmg/node_modules/ds-store/node_modules/macos-alias/build'
CXX(target) Release/obj.target/volume/src/volume.o
../src/volume.cc:9:2: error: #error This platform is not implemented yet
#error This platform is not implemented yet
package.json
{
"name": "Cuttle",
"homepage": "https://github.com/oakmac/cuttle",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/oakmac/cuttle.git"
},
"dependencies": {
"fs-extra": "0.16.3",
"open": "0.0.5",
"winston": "0.8.3"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-less": "0.11.4",
"grunt-contrib-watch": "0.6.1",
"grunt-curl": "2.0.3",
"grunt-download-atom-shell": "0.10.0",
"grunt-appdmg": "0.2.0",
"winresourcer": "0.9.0",
"moment": "2.9.0",
"shelljs": "0.3.0"
}
}
You can use an optional dependency.
Like this in your package.json:
"optionalDependencies":{
"grunt-appdmg":"0.2.0"
}
More info on NPM documentation
npm install will then just skip it if it fails.
Let me introduce handpick that lets you target and filter multiple dependencies. I wrote this to speed up CI stages that just need a fragment of the devDependencies but there are eventually more usecases. This project is quite experimental - please leave some feedback.
Installation
Install on your system:
npm install handpick --global
Usage
Run the command:
handpick [options]
-V, --version
-T, --target
-F, --filter
-M, --manager
-P, --path
-h, --help
Examples
Define unofficial dependencies inside package.json file:
{
"lintDependencies":
{
"eslint": "6.8.0",
"eslint-config-redaxmedia": "2.0.0"
},
"testDependencies":
{
"chai": "4.2.0",
"mocha": "7.1.1"
}
}
Install the lintDependencies:
handpick --target=lintDependencies
Install the devDependencies and lintDependencies via YARN:
handpick --target=devDependencies --target=lintDependencies --manager=yarn
Install the devDependencies without testDependencies:
handpick --target=devDependencies --filter=testDependencies
Install the dependencies and devDependencies within path:
handpick --path=../shared

Resources