Yeoman - Update node modules in app folder - node.js

I use Yeoman for creating and managing my apps;
after app is created, in the app's folder there are several node_modules installed (bower, grunt, grunt-cli ...)
What have I to do if I want all this node modules to be updated to their respective latest versions?
Now I manually go inside node modules' folders and run
npm update
one by one; but i wonder if there is a better way to do that...
Yeoman creates a package.json in the project's root folder; here's the file content:
{
"name": "webapp",
"version": "2.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.2-0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-coffee": "0.7.0",
"grunt-contrib-uglify": "0.2.4",
"grunt-contrib-compass": "0.5.0",
"grunt-contrib-jshint": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.2.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.1.3",
"grunt-contrib-livereload": "~0.1.2",
"grunt-rev": "~0.1.0",
"grunt-usemin": "~0.1.10",
"grunt-regarde": "~0.1.1",
"grunt-mocha": "~0.3.0",
"grunt-open": "~0.2.0",
"grunt-svgmin": "~0.1.0",
"grunt-concurrent": "~0.1.0",
"matchdep": "~0.1.1",
"grunt-ember-templates": "0.4.7",
"grunt-neuter": "0.5.0"
},
"engines": {
"node": ">=0.8.0"
}
}
but if I run npm update, it says that there is no "repository field"

You can just call "npm update" in your root project folder, right where your package.json file is. It will check for updates in all local and global modules.
Yeoman should create the package.json, so it should exist anyway.

Related

Segmentation 11 Error in Node Sass when running a Gulp Task

I've been battling with this issue for the past few hours now and all of the fixes I've found online have unfortunately not worked for me.
When running a gulp task, such as gulp deploy (I'm developing for Netsuite) the task will run until compiling SASS and then I get this error:
/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/lib/parse.js:14
return a.value;
^
TypeError: Cannot read property 'value' of null
at /Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/lib/parse.js:14:15
at Array.map (native)
at valuesFromArrayExpression (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/lib/parse.js:13:26)
at walk.ancestor.CallExpression (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/lib/parse.js:77:22)
at c (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/node_modules/acorn/util/walk.js:47:18)
at Object.skipThrough (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/node_modules/acorn/util/walk.js:163:39)
at c (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/node_modules/acorn/util/walk.js:46:17)
at Object.base.ExpressionStatement (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/node_modules/acorn/util/walk.js:176:5)
at c (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/node_modules/acorn/util/walk.js:46:17)
at Object.skipThrough (/Users/chrismartyr/Documents/GitHub/ChannelTen/node_modules/amd-optimize/node_modules/acorn/util/walk.js:163:39)
Segmentation fault: 11
I've tried removing and re installing the node modules, I've also tried different versions of node, unfortunately I have to use between 4.0.0 - LTS as if defined by the version of Suitecommerce Advanced I'm using.
I'm currently using node 4.9.1 and npm 2.15.11.
Watch tasks run fine, it's only when it's compiling the SCSS for production that this error occurs..
Heres the package.json:
{
"name": "suitecommerce-builder",
"version": "0.0.1",
"description": "Sets of tasks to build a Reference Implementation",
"main": "gulpfile.js",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"amd-optimize": "0.3.1",
"archiver": "0.13.0",
"async": "0.9.0",
"cli-spinner": "0.1.5",
"del": "0.1.1",
"escodegen": "1.6.1",
"esprima": "1.2.5",
"estraverse": "1.9.3",
"express": "4.13.3",
"glob": "4.0.4",
"gulp": "3.8.7",
"gulp-add": "0.0.2",
"gulp-bless": "3.0.1",
"gulp-changed": "1.0.0",
"gulp-concat": "2.3.3",
"gulp-cssfmt": "^1.0.0",
"gulp-handlebars": "3.0.1",
"gulp-if": "1.2.5",
"gulp-insert": "0.4.0",
"gulp-jshint": "1.9.0",
"gulp-jst": "0.1.1",
"gulp-less": "1.3.6",
"gulp-livereload": "2.1.1",
"gulp-minify-css": "0.3.13",
"gulp-sass": "2.1.0",
"gulp-sourcemaps": "1.2.8",
"gulp-svg2ttf": "1.0.3",
"gulp-ttf2eot": "1.0.1",
"gulp-ttf2woff": "1.0.1",
"gulp-uglify": "0.3.1",
"gulp-util": "3.0.1",
"handlebars": "2.0.0",
"inquirer": "0.5.1",
"is-my-json-valid": "2.13.1",
"jshint-stylish": "1.0.0",
"jsonlint": "1.6.2",
"jsonpath-plus": "0.15.0",
"lazypipe": "0.2.2",
"lodash": "2.4.1",
"map-stream": "0.1.0",
"mime": "1.2.11",
"moment": "2.8.3",
"node-sass": "3.4.1",
"ns-uploader": "file:./ns_npm_repository/ns-uploader",
"progress": "1.1.7",
"q": "1.0.1",
"request": "2.39.0",
"serve-index": "1.7.2",
"shelljs": "^0.5.3",
"short-jsdoc": "0.2.4",
"sourcemap-to-ast": "0.0.2",
"through": "2.3.6",
"through2": "0.6.3",
"underscore": "1.6.0",
"vinyl": "0.4.6",
"xml2js": "0.4.5",
"yargs": "1.3.1",
"credentials-inquirer": "file:./ns_npm_repository/credentials-inquirer",
"suitetalk": "file:./ns_npm_repository/suitetalk4node",
"preconditions": "file:./ns_npm_repository/preconditions",
"xmlbuilder": "8.2.2"
},
"optionalDependencies": {
"minijasminenode2": "1.0.0",
"gulp-jasmine-phantom": "1.1.2",
"fsevents": "0.3.7"
}
}
Any help would be very much appreciated?
Thanks!
I would recommend updating package.json's entry for amd-optimizer. The latest version as shown on https://www.npmjs.com/package/gulp-amd-optimizer is 0.6.0.
And as per https://docs.npmjs.com/cli/update, I'd recommend using the npm update command:
npm update amd-optimizer
You may need to specify the package version, in which case it will be amd-optimizer#0.6.0
Note, npm update also updates the package.json file according to the docs page.
You may need to be in the node_modules directory when running this command.
Hope this helps,

how to have same package-lock.json for all node / npm versions

Is it possible to have different node versions (lts and current) and have the same package-lock.json?
Currently when I run npm install the packages it generates are different to those specified in the package-lock.json file.
For example I'm using nvm (node version manager) to test different node versions on the same machine.
nvm exec v10.3.0 npm i outputs package-lock.json :
"babel-generator": {
"version": "6.26.1",
"resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz",
"integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==",
"dev": true,
"requires": {
"babel-messages": "^6.23.0",
"babel-runtime": "^6.26.0",
"babel-types": "^6.26.0",
"detect-indent": "^4.0.0",
"jsesc": "^1.3.0",
"lodash": "^4.17.4",
"source-map": "^0.5.7",
"trim-right": "^1.0.1"
}
},
nvm exec v8.11.2 npm i outputs package-lock.json :
"babel-generator": {
"version": "6.26.1",
"resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz",
"integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==",
"dev": true,
"requires": {
"babel-messages": "6.23.0",
"babel-runtime": "6.26.0",
"babel-types": "6.26.0",
"detect-indent": "4.0.0",
"jsesc": "1.3.0",
"lodash": "4.17.10",
"source-map": "0.5.7",
"trim-right": "1.0.1"
}
},
And because of that a lot of git conflicts keep happening between these two version.
Is there any configuration in package.json to have same output for package-lock.json ?

How to resolve gulp dependencies while creating a NPM package

I have a nodeJs application(demo) which using commander package to take command line argument and using gulp for
build
docs
test
coverage
This functionality is working fine but Now I need to move this application as a NPM Package.
Changes are done according to according NPM Package but when I install this as NPM package npm install ../demo/ from local location.
It asks for following gulp dependencies: -
Cannot find module gulp
Cannot find module gulp-load-plugins
Cannot find module del
Cannot find module gulp-plumber
Cannot find module gulp-eslint
Cannot find module babel-eslint
Cannot find module gulp-debug
Cannot find module gulp-sourcemaps
Cannot find module gulp-babel
Every time I go back to the npm package(which i created) directory and run the command which occurs as an error like npm install gulp --save-dev and npm install del --save-dev and so on.
I also defined these dependencies in package.json but it is still throwing errors.
Is there any way to resolve this issue.
package.json
{
"name": "demo",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"keywords": [],
"scripts": {
"build": "gulp build",
"coverage": "gulp coverage",
"docs": "gulp docs",
"prepublish": "gulp build",
"test": "gulp test"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-polyfill": "^6.6.1",
"commander": "^2.9.0",
"lodash": "^4.0.0",
"mustache": "^2.2.1",
"source-map-support": "^0.4.0",
"wrench": "^1.5.8",
"ms": "^0.7.1"
"babel-eslint": "^6.0.4",
"babel-plugin-lodash": "^2.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-nodejs-lts": "^1.2.2",
"chai": "^3.5.0",
"del": "^2.2.0",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.1.0",
"gulp-debug": "^2.1.2",
"gulp-esdoc": "^0.2.0",
"gulp-eslint": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-inject-modules": "^0.1.1",
"gulp-load-plugins": "^1.2.2",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"btoa": "^1.1.2",
"superagent": "^2.1.0"
},
"engines": {
"node": ">=4.0.0"
}
}
I put all the things in dependencies. I tried that way but having same problem.
npm install ../demo/
npm WARN package.json demo_project#1.0.0 No description
npm WARN package.json demo_project#1.0.0 No repository field.
npm WARN package.json demo_project#1.0.0 No README data
> demo#0.0.1 prepublish /work/demo
> gulp build
[16:53:33] Local gulp not found in ~/work/demo
[16:53:33] Try running: npm install gulp
Although the documentation doesn't mention it, npm install folder only installs dependencies and not devDependencies. This may be a little bit confusing as running npm install inside the package folder installs both dependenciesand devDependencies.
So try to install gulpand all the rest as npm install --save gulp (not
--save-dev)
UPDATE: after adding package.json:
everything under devDependencies in your package.json should be under dependencies:
{
"name": "demo",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"keywords": [],
"scripts": {
"build": "gulp build",
"coverage": "gulp coverage",
"docs": "gulp docs",
"prepublish": "gulp build",
"test": "gulp test"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-polyfill": "^6.6.1",
"commander": "^2.9.0",
"lodash": "^4.0.0",
"mustache": "^2.2.1",
"source-map-support": "^0.4.0",
"wrench": "^1.5.8",
"ms": "^0.7.1",
"babel-eslint": "^6.0.4",
"babel-plugin-lodash": "^2.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-nodejs-lts": "^1.2.2",
"chai": "^3.5.0",
"del": "^2.2.0",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.1.0",
"gulp-debug": "^2.1.2",
"gulp-esdoc": "^0.2.0",
"gulp-eslint": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-inject-modules": "^0.1.1",
"gulp-load-plugins": "^1.2.2",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"btoa": "^1.1.2",
"superagent": "^2.1.0"
},
"engines": {
"node": ">=4.0.0"
}
}

download unexpected file when run npm install

when I run npm install karma, my node_modules download a lot of unexpected files. I dont want to upload so many not related file to git.
when I run something like npm install angular, it will only download the file of angular, which is what I want.
may I know is there any config I need to do to fix it? thanks.
screenshot of my node_modules folder:
Thanks all for your reply. below is my package.json
is there any solution other than ignore these files?
there are too many, not just the one on screenshot.
And when I run npm install -g karma, I won't see these files
>
{
"name": "app",
"version": "1.1.1",
"description": "app: An Ionic project",
"dependencies": {
"gulp": "^3.5.6",
"gulp-sass": "^2.0.4",
"gulp-concat": "^2.2.0",
"gulp-minify-css": "^0.3.0",
"gulp-rename": "^1.2.0"
},
"devDependencies": {
"bower": "^1.3.3",
"gulp-util": "^2.2.14",
"karma": "^0.13.19",
"karma-chrome-launcher": "^0.2.2",
"karma-jasmine": "^0.3.6",
"shelljs": "^0.3.0"
},
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [
"ios",
"android"
],
"browser": {
"localforage": "./node_modules/localforage/dist/localforage.js",
"moment": "./node_modules/moment/moment.js",
"sjcl": "./node_modules/sjcl/sjcl.js",
"PouchDB": "./node_modules/pouchdb/dist/pouchdb.js"
},
"browserify": {
"transform": [
"browserify-shim"
]
},
"browserify-shim": {
"localforage": "localforage",
"moment": "moment",
"sjcl": "sjcl",
"PouchDB": "PouchDB"
}
}
These are probably modules which are sub modules of karma or some other module you are using.
If you don't want it in git, you can just ignore them by adding them to the gitignore file. In fact, you should probably add the entire node_modules folder to the file.

Node module generating a lot of subfolders

I'm running my build on jenkins but when I run npm install --color=false --loglevel warn it generate a lot of subfolders, and I can't even delete them on windows (I have to rename them before that).
It has started to happen today, we didin't manually update anything
My packages.json file
{
"name": "contratanet-portal",
"version": "0.1.0",
"description": "Builder do contratanet portal",
"private": true,
"devDependencies": {
"grunt": "~0.4.5",
"grunt-shell": "~0.7.0",
"grunt-msbuild": "~0.1.12",
"grunt-nuget": "~0.1.3",
"underscore": "~1.6.0",
"karma": "^0.12.23",
"karma-jasmine": "^0.1.5",
"requirejs": "^2.1.15",
"karma-chrome-launcher": "^0.1.4",
"karma-firefox-launcher": "^0.1.3",
"lodash": "^2.4.1",
"karma-opera-launcher": "^0.1.0",
"karma-safari-launcher": "^0.1.1",
"karma-ie-launcher": "^0.1.5",
"karma-junit-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^0.1.4",
"grunt-karma": "^0.9.0"
}
}

Resources