iView not defined error while trying to import it - javascript

I'm trying to import iView UI on my VueJS project with Webpack inside main.js.
import iView from 'iview'
Then:
Vue.use(iView)
And console shows up an error saying
Uncaught ReferenceError: iView is not defined
I added iview plugin by doing npm i iview -D on my project.
Why this isn't working? Any ideas? Maybe some package.json issues? whenever i run npm run dev it compiles everything fine, no errors, no warnings.

Okay, after some hours of attempts, I found out I had two ways of including this lib.
By either doing:
import iView from 'iview/dist/iview'
This one would throw a warning about types not defined for this, but if you do it like so:
const iView = require('iview')
It will work like a charm! Hope this helps to anyone who's under the same situation I was.

Related

Leaflet area select in Angular

I'm trying to use leaflet-area-select plugin in an Angular9 project, but I have a problem with it's usage.
Everytime I call this.map.selectArea VSCode tells me that property 'selectArea' does not exist on type 'Map'. How can I fix this?
I've installed leaflet-area-select with npm install --save leaflet-area-select and imported it in a component by using import { SelectArea } from 'leaflet-area-select';
Shall I do something else? The plugin documentation seems to be unclear about this.
I just ran into this issue and managed to fix it by changing the import reference from import { SelectArea } from 'leaflet-area-select'; to import 'leaflet-area-select';

Unable to resolve "../../App" from "node_modules\expo\AppEntry.js" Failed building JavaScript bundle

I cant open my vue file with expo. It gives AppEntry.js error. The problem is in AppEntry.js file my vue file hasnt seen so it gives error. I couldnt find how to add .vue extension. I need help guys this error drives me mad.
I updated my expo-cli and vue-native-cli and I use node 10.6.1 version.
node_modules/expo/AppEntry.js
import { registerRootComponent } from 'expo';
import { activateKeepAwake } from 'expo-keep-awake';
import App from "../../App" // The problem part is here. AppEntry doesnt accept .vue file I cant even see it.
if (__DEV__
)
{
activateKeepAwake();
}
registerRootComponent(App);
Also in same place
node_modules/expo/package.json
"sideEffects":
[
"*.fx.js",
"*.fx.web.js"
],
I tried to add .vue here and it didnt work for me. If you ask me to solve this we must add a code which provides AppEntry.js to read .vue extensions.
I expect see the App.vue page but I take AppEntry.js error.
I had similar issue, and I fixed it by installing 'expo-keep-awake' and 'react-native-unimodules' by using 'npm install react-native-unimodules' and 'npm install expo-keep-awake'.
According to this page, you should ensure that react-native-unimodules is installed when using the expo-keep-awake.
Hope this is helpful to you :)

process not defined when using npm react package

I am including npm react package in a script in the following way:
var react = require('react');
I am using node however when i do this and run my local node server i get the following error in the browser:
checkPropTypes.js:12 Uncaught ReferenceError: process is not defined
at Object.6../lib/ReactPropTypesSecret (checkPropTypes.js:12)
at s (_prelude.js:1)
at _prelude.js:1
at Object.8../checkPropTypes (factoryWithTypeCheckers.js:17)
at s (_prelude.js:1)
at _prelude.js:1
at Object.7../factoryWithTypeCheckers (factory.js:16)
at s (_prelude.js:1)
at _prelude.js:1
at Object.24../ReactElement (ReactPropTypes.js:16)
I'm not sure what is causing this error. I have tried to set NODE_ENV environmental variable using:
export NODE_ENV='development'
If anyone could shed any light on why i am getting this error that would be helpful.
Thanks in advance.

How Should I Add Toastr to my Angular 2/MVC Application

I am developing a project using Steve Sanderson's excellent template as a starting point (Angular Template for Visual Studio). I want to add Toastr functionality (Toastr) but every time I try and use it I get an error that "toastr is not defined".
I went about the following:
Added a dependency for "toastr": "2.1.2" to my package.json file.
Added both "toastr" (for the javascript) and "toastr/build/toastr.min.css" (for the css) to my webpack.config.vendor.json file.
From the command line ran webpack --config webpack.config.vendor.js.
I checked inside my vendor.css and could clearly see toastr styles. I checked inside my vendor.js and could see toastr methods. My application references both my vendor.css and vendor.js files. In fact Angular and Bootstrap styling all works fine so the references should be good.
To test Toastr functionality I wrote a very simple script
<script>toastr.success('Success')</script>
and placed it after the </body> but I got a console error in, Chrome F12, that toastr was not defined. I also tried to run the script within a click handler in an Angular component but received the same error.
Update
In my simple toastr.service.ts file which I created I added an import statement as follows: import * as toastr from "toastr"; and to prevent Typescript errors I then added: declare let toastr: any;.
The good news is My toastr service works. Frustratingly I have an error on my import statement saying "cannot find module toastr". Close.
Any suggestions why I am getting the warning and how to solve it very welcome.

Error on import statement in JavaScript/React Native code

I'm trying to incorporate a React component for radio buttons in my iOS app that's written in React Native, however I get an error when trying to import the component using the method that the author specified.
I first installed the component in the root directory of the app's XCode project/source code using the following statement:
npm i -S react-native-radio-buttons
Everything looked like it went through fine, so I incorporated the code for the component into the JS file for the screen that would use it, but I get an error on the very first line (which contains the import statement).
The import statement goes like this:
import { RadioButtons } from 'react-native-radio-buttons'
And the error is:
Uncaught SyntaxError: Unexpected reserved word
As far as I can tell, that should be an acceptable way of doing things in ES6. If anyone could tell me why this would happen, I'd be grateful. Thanks in advance.
react-native-radio-buttons author here,
I assumed everybody was using Babel with ES6 features enabled. I should add that to the README.
Edit: instruction and example .babelrc added to 0.4.2
Please try add this .babelrc file to your project root, as the provided example does:
{
"whitelist": [
"es6.modules"
]
}
Are you using a tool to translate from ES6? "import" is not going to work. Have you tried:
var RadioButtons = require('react-native-radio-buttons');
instead?

Categories

Resources