I want to run the meanjs existing project that I got from my friend in my mac pc but when I run the 'grunt' command then following error is getting:
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
after searching google I have used these two command below:
sudo npm install grunt --save-dev
npm install
but following errors are getting:
Loading "gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-tasks'
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
[NB: but grunt is working for the newly created meanjs project on my local mac but not for this old project from my friend]
Updated - I have the the package.json file here:
{
"name": "meanjsapp",
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js",
"version": "0.0.1",
"engines": {
"node": "0.10.x",
"npm": "1.4.x"
},
"scripts": {
"start": "grunt",
"test": "grunt test",
"postinstall": "bower install --config.interactive=false"
},
"dependencies": {
"apn": "^1.7.4",
"async": "~0.9.0",
"body-parser": "~1.9.0",
"bower": "~1.3.8",
"chalk": "~0.5",
"compression": "~1.2.0",
"connect-flash": "~0.1.1",
"connect-mongo": "~0.4.1",
"consolidate": "~0.10.0",
"cookie-parser": "~1.3.2",
"cron": "^1.0.9",
"express": "~4.10.1",
"express-session": "~1.9.1",
"forever": "~0.11.0",
"glob": "~4.0.5",
"grunt-cli": "~0.1.13",
"helmet": "~0.5.0",
"jsonwebtoken": "^5.0.2",
"jwt-simple": "^0.3.0",
"lodash": "~2.4.1",
"method-override": "~2.3.0",
"mongoose": "~3.8.8",
"morgan": "~1.4.1",
"multer": "^0.1.8",
"nodemailer": "~1.3.0",
"passport": "~0.2.0",
"passport-facebook": "~1.0.2",
"passport-github": "~0.1.5",
"passport-google-oauth": "~0.1.5",
"passport-linkedin": "~0.1.3",
"passport-local": "~1.0.0",
"passport-twitter": "~1.0.2",
"swig": "~1.4.1"
},
"devDependencies": {
"supertest": "~0.14.0",
"should": "~4.1.0",
"grunt-env": "~0.4.1",
"grunt-node-inspector": "~0.1.3",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-csslint": "^0.3.1",
"grunt-ng-annotate": "~0.4.0",
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-cssmin": "~0.10.0",
"grunt-nodemon": "~0.3.0",
"grunt-concurrent": "~1.0.0",
"grunt-mocha-test": "~0.12.1",
"grunt-karma": "~0.9.0",
"load-grunt-tasks": "~1.0.0",
"karma": "~0.12.0",
"karma-jasmine": "~0.2.1",
"karma-coverage": "~0.2.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2"
}
}
Can anybody help me?
A Node.js project, if used with npm, must come with a package.json file.
The package.json ( https://docs.npmjs.com/files/package.json ) file contains all the infos about the project, even the dependencies (which are added with the --save).
So if your friend did everything right you have just to run npm install and should install all the dependencies. If there's no package.json file or if there are no dependencies written on it, you have to install them manually.
grunt has many modules to work, and one of those is called load-grunt-tasks so you should run again npm install load-grunt-tasks --save-dev of course this is just if you do not have the dependencies in the file.
Related
I have certain node modules that i want to update. If i run npm outdated i see a list of modules and when i run npm update not all modules are updated.
I still see some in the list when i run npm outdated
my node version is v12.16.2
i see the below list when executing npm outdated
Below are the contents of my package.json
{
"name": "exporter",
"version": "1.0.0",
"description": "api endpoint",
"main": "server.js",
"dependencies": {
"#sentry/node": "5.30",
"abort-controller": "^3.0.0",
"archiver": "^5.2.0",
"aws-sdk": "^2.825.0",
"body-parser": "^1.19.0",
"bull": "^3.20.0",
"bull-board": "^0.9.0",
"config": "^3.3.3",
"cors": "^2.8.5",
"csv": "^5.3.2",
"dotenv": "^8.2.0",
"exceljs": "^4.2.0",
"express": "^4.17.1",
"express-basic-auth": "^1.2.0",
"express-rate-limit": "^5.2.3",
"fs": "0.0.1-security",
"generic-pool": "^3.7.1",
"helmet": "^4.3.1",
"jimp": "^0.16.1",
"JSONStream": "^1.3.5",
"jsonwebtoken": "^8.5.1",
"morgan": "^1.10.0",
"node-fetch": "^2.6.1",
"nodemailer": "^6.5.0",
"pg": "^8.6.0",
"pg-query-stream": "^4.1.0",
"pm2": "^4.5.1",
"puppeteer": "^5.5.0",
"rate-limit-redis": "^2.0.0",
"twitter": "^1.7.1",
"underscore": "^1.12.0",
"uuid": "^8.3.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "/usr/local/bin/pm2 restart all --update-env"
},
"author": "",
"license": "ISC"
}
How can i update all the below modules, specifically pm2 and puppeteer. Thanks.
npm update respects semver constraints.
This command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).
According to the package.json, the constraints are
#sentry/node: exact version
bull-board, dotenv, pm2, puppeteer: caret range
The packages are up-to-date according to these constraints.
To get the latest versions, you can install packages with the #latest tag.
Note that these are major version updates - things can break.
I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-preset-react-native. here is the error stack trace I am getting.
error: bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/Users/buraktas/workspace/reactnative'
- If you want to resolve "react-native", use "module:react-native"
at Function.module.exports [as sync] (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/node_modules/resolve/lib/sync.js:58:15)
at resolveStandardizedName (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/files/plugins.js:101:31)
at resolvePreset (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/files/plugins.js:58:10)
at loadPreset (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/files/plugins.js:77:20)
at createDescriptor (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/config-descriptors.js:154:9)
at items.map (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/config-descriptors.js:109:50)
at Array.map (<anonymous>)
at createDescriptors (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/config-descriptors.js:109:29)
at createPresetDescriptors (/Users/buraktas/workspace/reactnative/node_modules/#babel/core/lib/config/config-descriptors.js:101:10)
package.json
{
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"rnpm": {
"assets": [
"./assets/fonts/"
]
},
"dependencies": {
"axios": "^0.17.1",
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",
"react": "16.2.0",
"react-native": "^0.57.8",
"react-native-branch": "^2.3.0",
"react-native-camera": "^1.0.0",
"react-native-datepicker": "^1.6.0",
"react-native-deep-linking": "^2.1.0",
"react-native-fabric": "^0.5.1",
"react-native-keyboard-aware-scroll-view": "^0.4.3",
"react-native-modal": "^4.1.1",
"react-navigation": "^1.0.0-beta.22",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-form": "^7.1.2",
"redux-saga": "^0.16.0",
"stripe-client": "^1.1.3"
},
"devDependencies": {
"#babel/core": "^7.0.0",
"#babel/preset-flow": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.4.2",
"babel-preset-airbnb": "^3.2.0",
"detox": "^9.0.4",
"eslint": "^5.12.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.12.3",
"eslint-plugin-react-native": "^3.6.0",
"jest-cli": "^23.6.0",
"metro-react-native-babel-preset": "^0.51.1",
"react-test-renderer": "16.0.0",
"remote-redux-devtools": "^0.5.12"
},
"jest": {
"preset": "react-native"
}
}
.babelrc
{
"presets": [
"airbnb",
"#babel/preset-env",
"module:react-native",
"module:metro-react-native-babel-preset"
]
}
Deleting .babelrc file will fix this for you.
Please check react native upgrade helper
https://react-native-community.github.io/upgrade-helper
and specify your current React native version and the version to update (0.57 in your case)
You will see changes need to do in your case to make the code compatible with updated version
Looking at your package.json it looks like all you have done is upgrade the version of react-native to the latest version.
Unfortunately it is not as simple as changing the version number in the package.json. You don't state which version of react-native you were using before, but as you are using React 16.2.0 I would hazard a guess that you were on react-native 0.52 or 0.53.
To upgrade you should look at the diff that is provided between your version and the version that you upgrading to. rn-diff-purge shows the changes between that need to be performed. For upgrading 0.52.0 to 0.57.8 you can see the changes here, for 0.53.0 to 0.57.8 you can see the changes here.
You can check the changelog https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md to see more specific requirements for upgrading between the versions.
It is also worthwhile looking at https://facebook.github.io/react-native/docs/upgrading for tips on how to perform an upgrade.
I'm having trouble getting a Vue site to work consistently in IE11. I'm currently trying to use browserify to transpile with Babel to ES5, but seemingly it isn't working consistently (it sometimes works, but then after making a non-change to a JS file (such as adding a space to the end of a line) and then recompiling it will suddenly not work).
I'm seeing errors such as:
SCRIPT1006: Expected ')' in _typed_array.js
SCRIPT1002: Syntax error in _collection.js
So I believe this means the JS isn't being transpiled correctly into ES5?
Here's a copy of my package.json that contains all my build scripts:
{
"private": true,
"scripts": {
"watch-js": "watchify -vd -p browserify-hmr -e rest-theme/src/main.js -o rest-theme/dist/build.js",
"watch-scss": "./node_modules/.bin/node-sass -w --output-style=compressed scss/style.scss rest-theme/dist/build.css",
"dev": "npm run watch-scss | npm run watch-js",
"build": "cross-env NODE_ENV=production browserify rest-theme/src/main.js | uglifyjs -c warnings=false -m > rest-theme/dist/build.js"
},
"dependencies": {
"babel-polyfill": "^6.23.0",
"babel-runtime": "^6.9.2",
"mixitup": "^3.2.1",
"vue": "^2.1.1",
"vue-moment": "^2.0.1",
"vue-resource": "^1.0.0",
"vue-router": "^2.1.0",
"vue-smooth-scroll": "^1.0.13",
"viewport-units-buggyfill": "^0.6.0",
"vivus": "^0.4.1"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-2": "^6.0.0",
"babel-runtime": "^5.8.0",
"babelify": "^7.3.0",
"browserify": "^13.1.1",
"browserify-hmr": "^0.3.5",
"cross-env": "^1.0.6",
"node-sass": "^3.0.0",
"uglify-js": "^2.5.0",
"vue-hot-reload-api": "^2.0.6",
"vueify": "^9.3.0",
"vueify-insert-css": "^1.0.0",
"vue-migration-helper": "^1.1.1",
"watchify": "^3.7.0"
},
"browserify": {
"transform": [
"vueify",
["babelify", { "presets": ["es2015"] }]
]
},
"browser": {
"vue": "./node_modules/vue/dist/vue.common"
}
}
Nothing is really jumping out at me as to why it isn't compiling correctly; but perhaps there is something incorrect in my syntax, or an old version of something that is causing the build to fail sometimes?
I'm also including the babel polyfill on the first line of my main JS file:
import "babel-polyfill";
import VueRouter from 'vue-router';
import VueResource from 'vue-resource';
.....
But perhaps that is implemented incorrectly?
Let me know if I can provide more info, or additional script pieces to help illuminate anything!
I am having a weird problem, suddenly the nodemon stopped showing console log.
I am using npm run dev command to run the nodeJS app and my package.json looks like below,
{
"name": "loginform",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon app.js"
},
"dependencies": {
"async": "^2.1.4",
"body-parser": "^1.15.2",
"body-parser-xml": "^1.1.0",
"cassandra-driver": "^3.1.6",
"connect-flash": "^0.1.1",
"ejs": "^2.0.6",
"es6-template-strings": "^2.0.1",
"express": "^4.14.0",
"express-rate-limit": "^2.6.0",
"express-session": "^1.10.1",
"log-buffer": "0.0.3",
"mongodb": "^2.2.25",
"mongoose": "^4.7.0",
"nodemailer": "^0.7.1",
"passport": "^0.2.1",
"passport-facebook": "^1.0.3",
"passport-local": "^1.0.0",
"passport-twitter": "^1.0.2",
"qs": "^6.3.0",
"sweetalert2": "^6.5.5",
"trim": "0.0.1",
"url-pattern": "^1.0.3",
"uuid": "^3.0.1",
"xml2js": "^0.4.17"
},
"devDependencies": {
"nodemon": "^1.11.0"
}
}
I was working but suddenly stopped working, I am able to figure out why, though I had installed pm2 in between but uninstalled, is this the cause that might have broken the logging?
Update
This is how my console looks, no log at all.
Can anyone help with a solution?
Thanks.
You had a typo. I am sure you run this via npm run dev.
Try removing your node_modules folder, and re run npm install
I have a node.js app using Express and MongoDB (mongoose). It runs perfectly fine locally. I deployed it to heroku seemingly without a problem, but when I try to actually launch the app it crashes. The heroku log says this: Error: Cannot find module '/app/web.js'
I am new to this, so any help would be greatly appreciated. Thanks! App will help my Type 1 Diabetic daughter.
package.json:
{
"name": "projectglu",
"version": "0.0.0",
"dependencies": {
"express": "~3.4.3",
"lodash": "~2.4.1",
"mongoose": "~3.8.8",
"connect-mongo": "~0.4.0",
"passport": "~0.2.0",
"passport-local": "~0.1.6",
"ejs": "~0.8.4"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-autoprefixer": "~0.4.0",
"grunt-bower-install": "~0.7.0",
"grunt-concurrent": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.5.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-google-cdn": "~0.2.0",
"grunt-newer": "~0.5.4",
"grunt-ngmin": "~0.0.2",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~2.0.0",
"jshint-stylish": "~0.1.3",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.1",
"grunt-express-server": "~0.4.5",
"grunt-open": "~0.2.0",
"connect-livereload": "~0.3.0",
"karma-ng-scenario": "~0.1.0",
"grunt-karma": "~0.6.2",
"karma-firefox-launcher": "~0.1.3",
"karma-script-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.5",
"karma-chrome-launcher": "~0.1.2",
"requirejs": "~2.1.10",
"karma-requirejs": "~0.2.1",
"karma-coffee-preprocessor": "~0.1.2",
"karma-phantomjs-launcher": "~0.1.1",
"karma": "~0.10.9",
"karma-ng-html2js-preprocessor": "~0.1.0",
"grunt-mocha-test": "~0.8.1",
"supertest": "~0.8.2",
"should": "~2.1.0",
"grunt-env": "~0.4.1",
"grunt-node-inspector": "~0.1.3",
"grunt-nodemon": "~0.2.0",
"open": "~0.0.4"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "grunt test"
}
}
More clearly the problem may be when you create the Procfile from Heroku website example you are cutting and pasting "web: node web.js" which basically tells heroku which file is your entry point. You probably have a different entry point like say .. server.js so swap out "web: node web.js" with "web: node server.js" to solve your problem.
There is a variety of issues that can be causing this.
Please check that you have added your 'Procfile'.Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start a web dyno. In this case, you simply need to execute the Node script using node.
Here’s an example Procfile:
web: node web.js
Another culprit could be a misconfigured environment variable, NODE_ENV. Personally, commanding Heroku to set NODE_ENV=production helped me resolved a Cannot find module error I experienced. When you do this replace myapp with your Heroku app name.
heroku labs:enable user-env-compile -a myapp
heroku config:set NODE_ENV=production
If this fails to solve your issue move the packages declared in devDependencies over to dependencies just to mitigate the NODE_ENV issue.