I try to install time-grunt local and global, clear npm cache, update npm, but nothing helps.
I get:
Loading "Gruntfile.js" tasks...ERROR
Error: Cannot find module 'time-grunt'
Warning: Task "default" not found. Use --force to continue.
My version of packages:
node: '0.10.31',
npm: '1.4.23'
After run:
npm install --save-dev time-grunt
in package.json state:
"devDependencies": {
"grunt": "^0.4.5",
...
"time-grunt": "^1.0.0"
}
This is part of my grunfile.js:
module.exports = function( grunt ) {
require('time-grunt')(grunt);
grunt.initConfig({
// grunt tasks here
});
// load tasks here
// register task here
}
Other grunt tasks running without error.
I'm not understand what is wrong.
How I can test correctly installation of time-grunt by CLI?
You need to add it inside dependencies and not within devDependencies. This way you don't need to separately run $ npm install --save-dev time-grunt
{
"name": "grunt-build",
"version": "0.1.0",
"private": true,
"dependencies": {
"time-grunt": "^1.3.0"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "~0.7.0",
"grunt-contrib-compress": "~0.5.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-uglify": "~0.5.0",
"grunt-remove-logging": "~0.2.0"
}
}
use npm install or sudo npm install in the folder with package.json
I ended up installing all grunt dependencies manually.
npm install time-grunt
npm install load-grunt-config
and then all modules listed here:
Note: you can install all of the dependencies in the photo above in one go with npm install.
Finally I ran the grunt command and it worked!
Related
I only know npm install locally particular plugin into the dependencies object in the package.json. Been doing npm install -g on many packages manually, but how do I include it inside the package.json?
eg. my current package:
{
"name": "mypackage",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"lodash": "^4.17.15",
"react": "16.8.3",
}
}
To include my global install modules into mypackage
├── expo-cli#3.0.8
├── npm#6.9.0
├── npm-check-updates#3.1.20
├── react-devtools#4.1.0
├── react-native-cli#2.0.1
└── typescript#3.6.3
Go to your project root directory and execute,
npm install your-package-name
Or you can put the package-name manually in your package.json file and run,
npm install
But your package is already globally installed on your machine.
When you install an npm package, globally, using npm install -g my-package, then the package is globally available in your machine. You can use it anywhere in your machine.
But without global flag -g when you install a package, it only available inside the project scope.
So when a package is available globally, you do not need to install it in your project scope. It's a code redundant.
just type
$ npm install name-of-the-dependency
This is going to install the dependency in the package.json
The package will be added to your package.json when you install it from the project directory without -g
npm install --save package
you can also save the developer dependencies by
npm install --save-dev package
when you want to download a package for developers, such as grunt, gulp, then use this option
when you are distributing your code to production, these dependencies will not be available.
If you want to include packages like angular-cli you can install it as normal package and access it by referring the path inside the node_modules. like node_modules/.bin/ng build --prod
Appreciate with the guidance guys, just updated my question. So to add my global modules into mypackage gonna be like as per below?
{
"name": "mypackage",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"lodash": "^4.17.15",
"react": "16.8.3",
"expo-cli": "3.0.8",
"npm": "6.9.0",
"npm-check-updates": "3.1.20",
"react-devtools": "4.1.0",
"react-native-cli": "2.0.1",
"typescript": "3.6.3"
}
}
I'm trying to build a pipeline to deploy my website. I use grunt to compile less and minify CSS. This is how the gruntfile.js looks like:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less:{
development: {
options: {
path: ["assets/less/*.less"]
},
files: { "assets/css/style.css" : "assets/less/style.less" }
}
},
cssmin: {
options: {
sourceMap: false,
},
target: {
files: {"assets/css/style.min.css": "assets/css/style.css"}
}
},
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-less');
// Default task(s).
grunt.registerTask('default', ['less','cssmin']);
};
this is the package.json file:
{
"name": "lr-experience-builder",
"version": "0.1.0",
"devDependencies": {
"assemble-less": "^0.7.0",
"grunt": "^0.4.5",
"grunt-contrib-cssmin": "^1.0.2",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-less": "^1.4.0",
"grunt-contrib-nodeunit": "~0.4.1",
"install": "^0.8.1",
"npm": "^3.9.2"
}
}
I install the package in the pipeline in buddy.work, but everytime when I ran this pipeline, it throughs this error:
.......
Creating image finished.
grunt
Loading "less.js" tasks...ERROR
>> Error: Cannot find module './lodash'
Warning: Task "less" not found. Use --force to continue.
Aborted due to warnings.
Build failed !!!.
and this is how i config in the buddy.work pipeline:
npm install
npm install -g grunt-cli
npm install grunt --save-dev
npm install grunt-contrib-less --save-dev
npm install grunt-contrib-cssmin --save-dev
Does anyone have any ideas?
In your pipeline packages & setup commands, do this:
npm install -g grunt-cli
npm install lodash
npm install grunt --save-dev
npm install grunt-contrib-less --save-dev
npm install grunt-contrib-cssmin --save-dev
In the run command section do:
npm install
grunt
btw, check to clean cache when you ready to deploy.
I am trying to install the modules needed by my application using
npm install
When I do this, I get the following error:
npm ERR! Error: No compatible version found: gulp-util#'^3.0.0'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","1.0.0","1.1.0","1.1.1","1.2.0","1.3.0","2.0.0","2.1.1","2.1.2","2.1.3","2.1.4","2.2.0","2.2.1","2.2.2","2.2.3","2.2.5","2.2.6","2.2.7","2.2.8","2.2.9","2.
2.10","2.2.11","2.2.12","2.2.13","2.2.14","2.2.15","2.2.16","2.2.17","2.2.18","2.2.19","2.2.20","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6"]
However, I never require this module into my project.
I'm assuming it's an issue internal of npm or node.
Furthermore, also strange is that when I run
npm list -g
I get the following output rather than seeing the versions of npm which are installed.
├── node#0.0.0
My package.json file is:
{
"name": "myProject",
"version": "0.0.1",
"dependencies": {},
"scripts": {
"test": "gulp test"
},
"devDependencies": {
"browserify": ">=9.0.7",
"gulp": ">=3.8.11",
"gulp-concat": ">=2.6.0",
"gulp-html-replace": ">=1.5.1",
"gulp-react": ">=3.0.1",
"gulp-streamify": ">=1.0.2",
"gulp-uglify": ">=1.2.0",
"gulp-util": ">=3.0.6",
"reactify": ">=1.1.1",
"vinyl-source-stream": ">=1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
}
Your version of npm is so old that it doesn't support version ranges specified using ^. You are not using that syntax but it is quite likely one of the modules you are specifying is using that syntax for it's dependencies, and so when it tries to run npm install gulp-util#'^3.0.0' it throws that error.
If you update your npm either by updating node or by installing the latest npm with npm install -g npm then you should be able to proceed.
I deployed a node.js app in an azure "web apps" container. I added the "node_modules" folder to .gitignore and let azure install modules from package.json.
However, most modules do not get automatically installed and i have to open the instance's command line and install them manually using "npm install".
I am using node v0.12.0 and here is my package.json:
{
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"devDependencies": {
"body-parser": "^1.12.4",
"cors": "^2.6.1",
"express": "*",
"gulp": "^3.8.11",
"gulp-jshint": "^1.11.0",
"gulp-nodemon": "^2.0.3",
"moment": "^2.10.3",
"mongoose": "^4.0.3"
},
"engines": {
"node": "0.12.0"
}
}
How can I enable automatic installation of modules through azure web apps and not be obliged to push the "node_modules" folder with each commit?
Azure does not install the devDependencies.
If you need them on production, it is not devDependencies but dependencies
In your package.json, devDependencies should be renamed to dependencies
This kind of thing appens when you npm install --save-dev.
Production dependency (needed to run): npm install --save
Otherwise (build tools, jshint, etc.): npm install --save-dev
In my package.json, I have:
"devDependencies": {
"download": "^0.1.18",
"grunt": "^0.4.5",
"grunt-autoprefixer": "^0.8.0",
"grunt-contrib-imagemin": "^0.7.1",
"grunt-contrib-less": "^0.11.3",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-watch": "^0.6.1"
}
When I run npm install, it tries to install grunt-contrib-imagemin before anything else and it throws an error.
The workaround is to npm install download, THEN npm install grunt-contrib-imagemin manually, then npm install the rest of the packages.
Why doesn't npm install respect the order of the packages listed in devDependencies?