Please provide us with the following information:
- OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 10
ng --version. If there's nothing outputted, please runnode --version and paste the result here:angular-cli: 1.0.0-beta.14
node: 5.12.0
os: win32 x64
intlTelInput.js:15 Uncaught ReferenceError: jQuery is not defined(anonymous function) @ intlTelInput.js:15(anonymous function) @ intlTelInput.js:17
lang.js:310Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
I want to use jQuery plugin (https://github.com/jackocnr/intl-tel-input), but i cant connect it. I think that library cant connect with jQuery, because i can use jQuery in my project only that way: let jQuery = require('jQuery'); require('jquery') not working.
My angular-cli.json:
{
"project": {
"version": "1.0.0-beta.11-webpack.8",
"name": "order-page"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": "assets",
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css",
"../node_modules/intl-tel-input/build/css/intlTelInput.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/intl-tel-input/build/js/intlTelInput.js"
],
"environments": {
"source": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"dev": "environments/environment.dev.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"lazyRoutePrefix": "+"
}
}
package.json:
{
"name": "order-page",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/*_/_.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"core-js": "^2.4.0",
"intl-tel-input": "9.0.9",
"jquery": "^3.1.0",
"moment": "^2.15.0",
"ng2-bootstrap": "1.1.0",
"process-nextick-args": "^1.0.7",
"rxjs": "5.0.0-beta.11",
"ts-helpers": "^1.1.1",
"zone.js": "0.6.12"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/jquery": "^1.10.31",
"angular-cli": "1.0.0-beta.11-webpack.8",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "0.13.22",
"karma-chrome-launcher": "0.2.3",
"karma-jasmine": "0.3.8",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.3",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "^2.0.0"
}
}
import * as $ from 'jquery';
window['$'] = window['jQuery'] = $;
this how i do it
cant find module 'jquery'
npm i --save jquery
Is there any updates about this issue?
I am connect libraries using CDN, its working (jquery and jquery plugin)
@nikitarakitin I'm not using CDN libraries. I did installation of the package via npm, then install @types/jquery, include it in angular-cli.json's scripts entry, script from node_modules folder. After that, in my code just import jquery: import * as $ from 'jquery'; and it's working for me.
I got the same problem!
1. Install jquery using npm
npm install jquery --save
2 Install jQuery TypeScript autocomplete
npm install @types/jquery --save-dev
3 Adding to angular-cli.json
"scripts": [
"../node_modules/jquery/dist/jquery.min.js"
]
- In package.json
dependencies
"jquery": "^3.2.1",
4 I restart by : ng serve
But it is still occur message:
scripts.bundle.js:17 Uncaught ReferenceError: jQuery is not defined
Anyone have solve?
I had the same error, I solved it by updating node to latest version: https://nodejs.org/en/download/
then "npm cache --force clean" and then "npm install"
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
import * as $ from 'jquery';
window['$'] = window['jQuery'] = $;
this how i do it