What does it mean when ngAnnotate says "Cannot create property '$methodName'..." - javascript

I am in a bad situation. I need to make some small changes to a complex web application that I did not write myself. However, to begin with I cannot even get the application to build.
The project is using grunt to build the application. But when I run it I get the following error:
Running "ngAnnotate:dist" (ngAnnotate) task
Warning: Cannot create property '$methodName' on boolean 'false' Use --force to continue.
Aborted due to warnings.
Does anyone have a clue what this means and how I can fix it?
Note: If I run grunt --force it does complete building but the result looks all weird and is not functional.
I should probably add that I am pretty unfamiliar with web development, including with grunt.

There was some issue with older ngAnnotate package. grunt-ng-annotate depends on ngAnnotate. So you will have to update the grunt-ng-annotate package.
You can do so using "update grunt-ng-annotate" command in your project directory or by changing version to latest version in package.json then run npm install
Here is the link for the issue: https://github.com/olov/ng-annotate/issues/139
Hope it helps.

Related

Is it possible to run React project without npm start?

I'm in a big trouble. Working in a part time in a company they're looking for a new web technology to build "web-component" in their website.
They have started to use AngularJS (first version) and I told them that, with the recent evolution of this framework, it's not the right period of time to deal with it.
That's why I began to be interested in ReactJS. However, they don't have a node.js server infrastructure (and that's why AngularJS suits to them, only one browser is sufficient) so it's impossible to run it with something like "npm start".
SO ! My question is (as my post's title says...) :
Is it possible to run ReactJS without server side ?
I've tried with the following line in my header
<script src="https://unpkg.com/react#15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom#15/dist/react-dom.js"></script>
But it remains a blank page.
Maybe there is something I don't understant in the react structure and that's why I'm looking for some help/explanations from you.
I hope I have been clear enough ! Thank you in advance for answer.
It is absolutely possible to run a React app without a production node server. Facebook provides an easy-to-use project bootstrapper that you can read about here
That being said, developers may need to use a node dev server locally via npm start, as well as using node to perform production builds via npm run build. But one can take the build output from npm run build and serve it from any static server and have a working react application.
For those who are getting 404's after deploying in a sub directory. Make sure to add the path in package.json as homepage.
"homepage": "https://example.com/SUB-DIRECTORY",
You should insert "homepage": "./" into your package.json file, then use building react-script command like npm run build.
I did it by using serve, as part of the build step in Jenkins. To install it, execute the command:
npm install -g serve
Then, to serve it:
serve -s build
Please, refer to project page for more information: https://github.com/zeit/serve

Lite-server does not detect a `bs-config.json` or `bs-config.js` override file

I'm trying to run angular2 based first app. I followed angular2 steps. When i run command npm start then its giving following error in the terminal
Did not detect a bs-config.json or bs-config.js override file. Using lite-server defaults...
And also browser returning 404 error for index.html file (angular-project/app/index.html)
I check lite-server version is "lite-server#^2.2.0", and npm version 3.7.3, also i followed this accepted answer instructions but still facing same issue. Can anyone guide me how can fix it, I will appreciate. Thank You.
In Wrap up section different project structure than described in question. Please ensure that you have followed tutorial correctly.
I see you are running lite-server 2.2.0; anyone else looking for help with this error should make sure they are running lite-server 2.0 or greater as that's when config file support was introduced.
Also, it can throw this error if there is a problem executing the bs-config.js, so check your config file for anything that could be erroring (including but not limited to syntax errors). For me I had forgotten to install the http-proxy-middleware so lite-server errored when it tried to execute the first line of my bs-config.js, which was var proxy = require('http-proxy-midleware');. An npm install --save-dev http-proxy-middleware fixed this error for me.
HT: this github issue.
The reason that you have seen this warning message
Did not detect a bs-config.json or bs-config.js override file. Using lite-server defaults...
is probably that you have a definition in your package.json which describes what should happen once you trigger the npm start command, like:
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server -c bs-config.json\" ",
...
}
Therefore, in short you need to either provide the bs-config.json file with the desired browser-sync configuration or modify the the above command.
Moreover, angular2 has now its famous quick-start example on github.
I made this account specifically to second the answer made by Patrick on July 12th.
If your bs-config cannot be found it may be because you do not have the proper packages. In my case I had http-proxy-middleware, but was missing connect-history-api-fallback.
Make sure to check/install all the node packages used in your bs-config!

Hive connector from nodejs

I want to query a hive database table from node js. I searched in npm and found two packages - node-hive and thrift-hive, but problems with both as follows
1) node-hive: When I try to run using this, there are many missing dependencies finally didn't get the module 'thrift/transport'
2) thrift-hive: When I try to run using this, query is running forever and not even doing a timeout. I suspect that the libraries they used are for old versions of hive.
The version we are using for hive is 1.1.0-cdh5.4.1.
Is there anything I am missing or is there any proper hive connectors in npm. Thanks in advance
If you want to resolved that dependencies issue then you need to first install thrift module with 0.9.1 version.
So add "thrift":"0.9.1" in your package.json and run npm install.
After that you will not get 'thrift/transport' module dependencies error. Furthermore, even I am curious to know about which npm is best suitable to connect to hive. I am using node version 0.12.7.

Custom build with core-js

I'm trying to create a custom build with core-js. Per the documentation, I first ran
npm i core-js && cd node_modules/core-js && npm i
which seemed to be fine. Then, also per the docs I tried
C:\GIT\coreJS_Custom\node_modules\core-js>npm run grunt build:es6.array.from -- --library=on --path=custom uglify
and lots of variations on that theme. It seems to run briefly, with no output at all, and I can't seem to find any generated file. What am I doing wrong?
Also, the above commands were run on the Windows 8.1 cmd terminal.
What's particularly interesting (and frustrating) is that running this
C:\GIT\coreJS_Custom\node_modules\core-js>npm run grunt kjhgjhghkghh
Similarly runs briefly and then seems to succeed.
I'm not sure what my root problem is, but for me, running the grant task on its own, without npm run did the trick
So something like this should be the final product.
C:\GIT\coreJS_Custom\node_modules\core-js>grunt build:es6.array.from --library=on --path="es6-array-from-build-min2" uglify

Grunt grunt-contrib-jasmine

I have recently started to use grunt for JS project.
I have got a plugin called 'grunt-contrib-jasmine' that I'm using for Jasmine testing. I works great but I'm not able to run tests by specrunner in browser. Can I achieve this by using this plugin or do I need to install something else.
Also when a plugin is not required anymore, is it best to just comment it out or is there any command to uninstall, eg: npm uninstall grunt-contrib-jasmine --save-dev
Just for clarification, you can load the _SpecRunner.html file manually in the browser, but the grunt plugin will only run the tests in PhantomJS.
You can specify the keepRunner:true option in your gruntfile to keep the _SpecRunner.html file around after the tests run.
Then you can start a static web server (grunt-contrib-connect, and node-static both work fine for me) to the root of your project, and you should be able to manually open that _SpecRunner.html in a browser and run your tests there.
EDIT: I ended up giving Testem a try, which can launch your tests in PhantomJS and real browsers. It's still early, but I think I'll be setting aside grunt-contrib-jasmine in favor of Testem and grunt-contrib-testem.
grunt-contrib-jasmine is only for headless browser (phantomjs) so I afraid you will not be able to run this in browser. You will need to set up that manually.
In order to uninstall a plugin, use the command you mentioned:
It will remove the entry from package.json and it'll also uninstall the package too.

Categories

Resources