I am running a Node app with an npm configuration in WebStorm but I cannot debug, I keep getting the error below.
I have a clean system with node 16.5.0 installed along with npm
The app runs or when you just run it.
"c:\Program Files\nodejs\npm.cmd" run start
Debugger listening on ws://127.0.0.1:63505/499bdffd-e2d2-40af-9e44-0fc1b93a7404
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
^C^CTerminate batch job (Y/N)?
Process finished with exit code 1
Here is my package.json
{
"name": "storefront_backend",
"version": "0.1.0",
"description": "",
"main": "server.ts",
"scripts": {
"build": "tsc --build",
"start": "ts-node src/server.ts",
"watch": "tsc-watch --esModuleInterop src/server.ts --outDir ./dist --onSuccess \"node ./dist/server.js\"",
"test": "tsc -p . & mocha ./src/spec/*.js",
"tsc": "tsc"
},
"author": "Udacity",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"db-migrate": "^0.11.13",
"db-migrate-pg": "^1.2.2",
"dotenv": "^16.0.1",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"pg": "^8.5.1",
"typescript": "^4.1.3"
},
"devDependencies": {
"#types/chai": "^4.3.1",
"#types/express": "^4.17.9",
"#types/jasmine": "^3.10.6",
"#types/mocha": "^9.1.1",
"#types/node": "^17.0.35",
"#types/pg": "^7.14.7",
"bcrypt": "^5.0.1",
"chai": "^4.3.6",
"chai-http": "^4.3.0",
"eslint": "^8.16.0",
"jasmine": "^3.6.4",
"jasmine-spec-reporter": "^6.0.0",
"jasmine-ts": "^0.3.0",
"jest": "^28.1.0",
"mocha": "^10.0.0",
"request": "^2.88.2",
"supertest": "^6.2.3",
"ts-node": "^9.1.1",
"tsc-watch": "^4.2.9"
}
}
Must be WEB-55884 that is fixed in 2022.1.2. Workaround: open Settings | Languages & Frameworks | Node.js and set Package manager to npm package folder, e.g. C:\Program Files\nodejs\node_modules\npm.
Related
I have a front-end build, which I was given and which I am trying to get to build. Whenever I run yarn run dev, I get the following:
(base) ➜ project git:(master) ✗ yarn run dev
yarn run v1.22.17
$ gulp
[22:18:45] Requiring external module #babel/register
ReferenceError: require is not defined
at file:///home/user/sites/project/gulpfile.babel.js:5:20
at ModuleJob.run (internal/modules/esm/module_job.js:145:37)
at async Loader.import (internal/modules/esm/loader.js:182:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What can I do to troubleshoot and fix this?
My installation steps were as follows:
yarn global add gulp-cli
yarn global add bem-tools-core
yarn
yarn run dev
I have tried installing with npm as well, just in case it might make a difference. It does not. The same error persists.
The top of the gulpfile.babel.js looks as follows:
"use strict";
import gulp from "gulp";
const requireDir = require("require-dir"),
paths = {
views: {
src: [
"./src/views/index.pug",
"./src/views/pages/*.pug"
],
The package.json is like this:
{
"name": "gulp-pug-starter",
"description": "Frontend development with pleasure",
"author": "Andrey Gorokhov",
"repository": {
"type": "git",
"url": "https://github.com/andreyalexeich/gulp-pug-starter.git"
},
"license": "MIT",
"type": "module",
"babel": {
"presets": [
"es2015"
]
},
"scripts": {
"dev": "gulp",
"build": "gulp prod --production",
"build:views": "gulp views --production",
"build:styles": "gulp styles --production",
"build:scripts": "gulp scripts --production",
"build:images": "gulp images --production",
"build:webp": "gulp webp --production",
"build:sprites": "gulp sprites --production",
"build:fonts": "gulp fonts --production",
"build:favicons": "gulp favicons --production",
"build:gzip": "gulp gzip --production",
"lint:styles": "stylelint \"src/**/*.scss\" --syntax=scss",
"lint:styles --fix": "stylelint \"src/**/*.scss\" --syntax=scss --fix",
"lint:scripts": "eslint --color ./src/blocks",
"lint:scripts --fix": "eslint --fix --color ./src/blocks",
"bem-c": "bem create $* -l src/blocks/components",
"bem-m": "bem create $* -l src/blocks/modules"
},
"devDependencies": {
"#babel/core": "^7.4.3",
"#babel/preset-env": "^7.4.3",
"#babel/register": "^7.17.0",
"babel-eslint": "~10.1.0",
"babel-loader": "^8.0.5",
"babel-register": "^6.26.0",
"bem-tools-core": "bem-tools/bem-tools-core",
"bem-tools-create": "bem-tools/bem-tools-create",
"browser-sync": "^2.23.6",
"del": "^5.1.0",
"eslint": "~7.7.0",
"gulp": "^4.0.0",
"gulp-autoprefixer": "~7.0.1",
"gulp-clean-css": "~4.3.0",
"gulp-debug": "~4.0.0",
"gulp-favicons": "^2.3.1",
"gulp-group-css-media-queries": "^1.2.2",
"gulp-if": "^3.0.0",
"gulp-imagemin": "~7.1.0",
"gulp-newer": "^1.4.0",
"gulp-plumber": "^1.2.0",
"gulp-pug": "^4.0.1",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.0.0",
"gulp-sass": "~4.1.0",
"gulp-sourcemaps": "^2.6.4",
"gulp-svg-sprite": "^1.5.0",
"gulp-watch": "^5.0.0",
"gulp-webp": "^4.0.1",
"husky": "^4.2.1",
"imagemin-giflossy": "^5.1.10",
"imagemin-jpeg-recompress": "~7.0.0",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-pngquant": "~9.0.0",
"imagemin-webp": "^6.0.0",
"imagemin-zopfli": "^7.0.0",
"lint-staged": "^10.0.3",
"require-dir": "^1.2.0",
"stylelint": "^13.6.1",
"stylelint-order": "^4.1.0",
"stylelint-selector-bem-pattern": "^2.1.0",
"webpack": "~4.44.1",
"webpack-stream": "^5.2.1",
"yargs": "~15.4.1"
},
"dependencies": {
"bootstrap": "^5.1.1",
"gsap": "./gsap-bonus.tgz",
"headroom.js-latest": "^0.9.6",
"jquery": "^3.6.0",
"jquery-ui_1.12": "^1.12.0",
"magnific-popup": "^1.1.0",
"owl.carousel": "^2.3.4",
"popper.js": "^1.16.1",
"smart-grid": "^2.1.2",
"swiper": "6.8.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"!(_*).scss": [
"stylelint --fix --color --config ./.stylelintrc"
],
"*.js": [
"eslint --fix --color"
]
}
}
Any something wrong with my package.json? The test is green when I run npm run test. But when I run npm run dev, the test is also run. There is no command config I write that it should run test when I run npm run dev
here is my package.json
"name": "domundotech-cashier",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "set DEBUG=domundotech-cashier:* & nodemon --exec & npm start",
"test": "node ./node_modules/mocha/bin/mocha \"*/*.spec.js\""
},
"dependencies": {
"acorn": "^8.1.0",
"body-parser": "^1.19.0",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"debug": "~2.6.9",
"dotenv": "^8.2.0",
"eslint-plugin-jest": "^24.3.3",
"express": "~4.16.1",
"express-useragent": "^1.0.15",
"http-errors": "~1.6.3",
"install": "^0.13.0",
"jade": "~1.11.0",
"moment-timezone": "^0.5.33",
"morgan": "~1.9.1",
"mysql2": "^2.2.5",
"node-device-detector": "^1.3.4",
"npm": "^7.8.0",
"request": "^2.88.2",
"sequelize": "^6.6.2",
"typescript": "^4.2.3"
},
"devDependencies": {
"sequelize-test-helpers": "^1.3.2",
"proxyquire": "^2.1.3",
"mocha": "^8.3.2",
"chai": "^4.3.4",
"sinon": "^10.0.0",
"sinon-chai": "^3.6.0",
"supertest": "^6.1.3",
"#typescript-eslint/eslint-plugin": "^4.20.0",
"#typescript-eslint/parser": "^4.20.0",
"eslint": "^7.23.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"sequelize-cli": "^6.2.0"
}
}
and this for the error logs
Describe is defined in my test file. For now, I found the solution that I should ignore (-i) test files when executing nodemon :)
"start": "node ./bin/www",
"dev": "set DEBUG=domundotech-cashier:* & nodemon -i ./test & npm start",
"test": "mocha \"./test/*/*.spec.js\""
},
And I refactor my project structure too
I was getting error installing expressJs to my packages. I have had to do an npm cache clean --force no sucess, then I deleted my node_modules and package-lock.json, I try to reinstall packages using npm i I still got an error.
Now I deleted node.js from my pc windows 10 and downloaded and installed the latest node and tried to reinstall the project packages again. Now the error I get is this
$ npm i
npm ERR! Unexpected end of JSON input while parsing near '...ncies":{"autoprefixer'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Chioma Onyepere\AppData\Roaming\npm-cache\_logs\2019-05-28T20_26_29_676Z-debug.log
My app is built on nextJs
Here's the package.json
{
"name": "ratethis",
"version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next",
"build": "next build",
"now-build": "next build",
"start": "next start -p %PORT%"
},
"repository": {
"type": "git",
"url": "git+https://github.com/infinity-web-development/ratethis"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/infinity-web-development/ratethis/issues"
},
"homepage": "https://github.com/infinity-web-development/ratethis#readme",
"dependencies": {
"#zeit/next-css": "^1.0.1",
"antd": "^3.15.1",
"faker": "^4.1.0",
"next": "^8.0.3",
"next-images": "^1.1.1",
"next-redux-wrapper": "^3.0.0-alpha.2",
"now": "^15.0.6",
"prop-types": "^15.7.2",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react-polls": "^1.2.0",
"react-redux": "^7.0.1",
"redux": "^4.0.1",
"redux-saga": "^1.0.2",
"shallow-equal": "^1.1.0",
"uuid": "^3.3.2"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-plugin-import": "^1.11.0",
"babel-plugin-inline-import": "^3.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-standard": "^4.0.0",
"next-antd-aza-less": "^1.0.2"
}
}
I had to delete all of npm-cache directly from my windows 10 pc, from %AppData%, ie ~/AppData\Roaming\npm-cache. Everything works fine now.
I would solve a warning: when I run yarn install all dependencies are installed but I receive this warning:
warning Pattern ["esprima-fb#~3001.0001.0000-dev-harmony-fb"] is
trying to unpack in the same destination
"/Users/Me/Library/Caches/Yarn/v1/npm-esprima-fb-3001.1.0-dev-harmony-fb-b77d37abcd38ea0b77426bb8bc2922ce6b426411"
as pattern ["esprima-fb#~3001.1.0-dev-harmony-fb"]. This could result
in a non deterministic behavior, skipping.
If I delete node_modules folder and I run yarn install I don't receive the warning, when I re-execute yarn install I receive it again.
I suppose the problem is in yarn-lock file.
package.json
{
"name": "n1",
"version": "1.0.0",
"description": "none ",
"author": "none",
"main": "src/index.js",
"private": false,
"engines": {
"node": ">=7.6",
"yarn": "*"
},
"scripts": {
"precommit": "yarn lint",
"prestart": "yarn docs",
"start": "cross-env NODE_ENV=production pm2 start ./src/index.js",
"dev": "nodemon ./src/index.js",
"lint": "eslint **/*.js --ignore-path .gitignore --ignore-pattern internals/scripts",
"lint:fix": "yarn lint -- --fix",
"lint:watch": "yarn lint -- --watch",
"test": "cross-env NODE_ENV=test nyc --reporter=html --reporter=text mocha --timeout 20000 --recursive src/api/tests",
"test:unit": "cross-env NODE_ENV=test mocha src/api/tests/unit",
"test:integration": "cross-env NODE_ENV=test mocha --timeout 20000 src/api/tests/integration",
"test:watch": "cross-env NODE_ENV=test mocha --watch src/api/tests/unit",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"postcoverage": "opn coverage/lcov-report/index.html",
"validate": "yarn lint && yarn test",
"postpublish": "git push --tags",
"docs": "apidoc -i src -o docs",
"postdocs": "opn docs/index.html"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"blubird": "^0.0.1-security",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"chalk": "^2.3.0",
"color": "^2.0.1",
"compression": "^1.7.1",
"cookie-parser": "^1.4.3",
"cors": "^2.8.4",
"cross-env": "^5.1.3",
"dotenv-safe": "^4.0.4",
"espree": "^3.5.2",
"esprima": "^4.0.0",
"express": "^4.16.2",
"express-validation": "^1.0.2",
"express-winston": "^2.4.0",
"helmet": "^3.9.0",
"http-status": "^1.0.1",
"joi": "^10.6.0",
"jwt-simple": "^0.5.1",
"lodash": "^4.17.4",
"method-override": "^2.3.10",
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",
"mongoose": "^4.13.7",
"morgan": "^1.9.0",
"morgan-body": "^2.0.2",
"mysql": "^2.15.0",
"mysql2": "^1.5.1",
"nedb": "^1.8.0",
"node-geocoder": "^3.21.1",
"only": "0.0.2",
"passport": "^0.4.0",
"passport-jwt": "^3.0.1",
"pm2": "^2.9.1",
"readline-sync": "^1.4.7",
"request-promise": "^4.2.2",
"sequelize": "^4.28.6",
"serve-favicon": "^2.4.5",
"winston": "^2.4.0",
"yarn": "^1.3.2"
},
"devDependencies": {
"apidoc": "^0.17.5",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"coveralls": "^2.13.1",
"eslint": "^4.13.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"husky": "^0.14.3",
"mocha": "^3.5.3",
"nodemon": "^1.14.1",
"nyc": "^11.4.1",
"opn-cli": "^3.1.0",
"sinon": "^3.3.0",
"sinon-chai": "^2.14.0",
"supertest": "^3.0.0"
},
"license": "MIT"
}
yarn-lock
https://pastebin.com/vTrLHWff
Try removing both node_modules and yarn.lock:
rm -rf node_modules and rm yarn.lock
And then try running:
npm run rebuild which seem to help to resolve the issue.
I have existing Ember js project on 2 computers, but I have problems with installation on a new one.
I do install on such way:
git clone <repository-url>
cd projectfolder
npm install
bower install
ember serve
It compiles but on browser I see such errors:
event-factory.js:3 - Uncaught SyntaxError: Unexpected token import
application.js:1 - Uncaught ReferenceError: define is not defined
Seems like some error with babel.
I have such package.json
{
"name": "project",
"version": "2.0.0",
"description": "",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"repository": {
"type": "git",
"url": "..."
},
"engines": {
"node": ">= 0.12.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "2.4.1",
"ember-cli": "^2.10.0",
"ember-cli-app-version": "^2.0.0",
"ember-cli-babel": "^5.1.7",
"ember-cli-data-export": "0.1.26",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-deploy": "*",
"ember-cli-deploy-build": "*",
"ember-cli-deploy-gzip": "*",
"ember-cli-deploy-revision-data": "*",
"ember-cli-deploy-s3": "*",
"ember-cli-deploy-ssh-index": "*",
"ember-cli-google-fonts": "1.13.0",
"ember-cli-htmlbars": "^1.0.10",
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^2.0.1",
"ember-cli-moment-shim": "1.2.0",
"ember-cli-pagination": "2.2.3",
"ember-cli-qunit": "^3.0.1",
"ember-cli-release": "0.2.9",
"ember-cli-sri": "^2.1.0",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-content-editable": "0.10.0",
"ember-data": "^2.10.0",
"ember-data-change-tracker": "0.5.5",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-metrics": "0.8.1",
"ember-notify": "^5.2.0",
"ember-power-select": "1.0.0",
"ember-radio-button": "1.1.1",
"ember-resolver": "^2.0.3",
"ember-select-guru": "^1.1.2",
"ember-simple-auth": "1.1.0",
"ember-simple-auth-loopback": "1.1.0",
"ember-truth-helpers": "1.2.0",
"ember-welcome-page": "^1.0.3",
"loader.js": "^4.0.10",
"mock-socket": "^6.0.4"
},
"dependencies": {
"ember-cli": "^2.11.1",
"ember-cli-babel": "^5.2.4",
"ember-cli-deploy": "^1.0.0",
"ember-cli-deploy-gzip": "^0.2.4",
"ember-cli-deploy-revision-data": "^0.3.3",
"ember-cli-deploy-s3": "^0.4.0",
"ember-cli-inject-live-reload": "^1.6.1",
"ember-cli-qunit": "^3.1.1",
"ember-data": "^2.11.3",
"ember-websockets": "6.3.0",
"loader.js": "^4.2.2"
}
}
and bower.json:
{
"name": "getprospect",
"dependencies": {
"ember": "v2.10.2",
"ember-cli-shims": "0.1.3",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0",
"bootstrap": "^3.3.6",
"jquery-stupid-table": "^1.0.1",
"jquery-auto-grow-input": "*",
"file-saver": "*",
"js-xlsx": "~0.8.0",
"fullcalendar": "^2.7.1",
"moment": "^2.17.1",
"moment-timezone": "^0.5.11",
"ember-simple-auth": "^0.8.0",
"raven-js": "^3.2.1",
"urijs": "^1.18.8",
"socket.io-client": "^1.7.2"
}
}
I've successfully installed this project some month ago, but can't figure out why is not launching on this machine... Any help appreciated.
The problem you had is most probably using ^ for your dependencies. What ^ (caret) does is upgrading your dependencies to a major version when you do a clean install. For instance if your dependency to an addon is let's say 1.2.0 and you used ^1.2.0 and there is a new version available 1.3.0, you will get this new major version. If you use ~ (tilda) instead of ^, then you will not get 1.3.0 but 1.2.2 for instance if available. In order to use the exact versions so that your dependencies will not change when you do a clean npm install, you can remove both caret and tilda in your dependency definitions.
In order to figure out which of your dependencies is outdated you can use npm outdated.