how to include a local javascript im ember-cli application - ember-cli

I have a local javascript in my application that i want to include in my ember-cli application.
it is called carrotsearch.foamtree.js
In order that it will be included i put it under vendor\foamtree\carrotsearch.foamtree
and in the app.js i write
import CarrotSearchFoamTree from 'foamtree/carrotsearch.foamtree'
the problem is that i get an error
===== 1 JSHint Error
Build failed. ENOENT, no such file or directory
'C:\Users\davidga\Desktop\ember\nextgen\tmp\tree_merger-tmp_dest_dir-37cYqLzL.tmp\foamtree\carrotsearch.foamtree.js'
File: foamtree/carrotsearch.foamtree.js Error: ENOENT, no such file or directory C:\Users\davidga\Desktop\ember\nextgen\tmp\tree_merger-tmp_dest_dir-37cYqLzL.tmp\foamtree\carrotsearch.foamtree.js'
at Object.fs.statSync (fs.js:689:18) at addModule
(C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-cli\no
de_modules\broccoli-es6-concatenator\index.js:83:46) at addModule
(C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-cli\no
de_modules\broccoli-es6-concatenator\index.js:126:9) at
C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-cli\node_modules\
broccoli-es6-concatenator\index.js:59:7 at tryCatch
(C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-cli\nod
e_modules\rsvp\dist\commonjs\rsvp-internal.js:163:16) at
invokeCallback
(C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-c
li\node_modules\rsvp\dist\commonjs\rsvp-internal.js:172:17) at
publish
(C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-cli\node
_modules\rsvp\dist\commonjs\rsvp-internal.js:150:13) at flush (C:\Users\davidga\Desktop\ember\nextgen\node_modules\ember-cli\node_m
odules\rsvp\dist\commonjs\rsvp\asap.js:51:9) at
process._tickCallback (node.js:419:13)
I thought that the problem is maybe bower related so i followed the following post how to include a private local file in javascript project using bower
The problem is that neither
"foamtree": "foamtree/carrotsearch.foamtree.js"
nor
"foamtree": "vendor/foamtree/carrotsearch.foamtree.js"
works.
What may i do?
Thanks,
David

I found an answer.
In brocfile.js we can add the line
app.import('vendor/foamtree/carrotsearch.foamtree.js')
I don't know if this is an optimal anser but it works
Update:
This solution is stated in the ember-cli documentation
http://iamstef.net/ember-cli/#managing-dependencies

If you don't need them to minified in your vendor.js file you can put them in the public/js and then include it as a normal script file in app/index.html. I use this method for some libraries like moment.js.
The public folder gets directly copied to your site root during the build.

Related

trying to connect postgresql to go but I'm getting an error

I've imported a module called "github.com/lib/pq". before I ran my code, I inserted this in the terminal % go get github.com/lib/pq. Then when i tried to run my code, I'm getting an error message in the terminal
'no required module provides package github.com/lib/pq: go.mod file not found in current directory or any parent directory; see 'go help modules'
Running go mod tidy will sync your go.mod and go.sum file with the imports in your code, this will add missing dependencies and remove unnecessary ones. Should solve your issue.

I have an error when executing ionic serve

When I execute ionic serve, it shows the following errors:
Refused to load the image 'http://localhost:8100/favicon.ico' because
it violates the following Content Security Policy directive:
"default-src 'none'". Note that 'img-src' was not explicitly set, so
'default-src' is used as a fallback.
Failed to load resource: the server responded with a
status of 404 (Not Found)
How can I solve this?
I had the same error message.
Looking through the logs printed when doing
ionic serve
showed me a bunch of errors, all similar to this
[ng] ERROR in ./src/global.scss (./node_modules/#angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/global.scss)
[ng] Module build failed (from ./node_modules/sass-loader/lib/loader.js):
[ng] Error: Cannot find module 'node-sass'
[ng] Require stack:
This lead me to get the application up and running again by
npm install node-sass --save
The compilation process is sometimes spitting out rather confusing error messages from time to time, but with a little digging one can start guessing where to start poking
I had the same issue. I was able to solve it. I fixed the routing file, I had a route that couldn't load because another route was higher order.
Ionic include default favicon icon into index.html file.
<link rel="icon" type="image/png" href="assets/icon/favicon.png" />
You can put your favicon icon into "assets/icon" and replace href above.
I had this error and it was because I had included an import I wasn't actually using. In my example, I had accidently imported Console when using console.log.
I was getting error TS2307: Cannot find module 'console'. in the VS Code terminal, but my error in Chrome was "Refused to load the image 'http://localhost:8100/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.
Failed to load resource: the server responded with a status of 404 (Not Found)"
So be aware that this error is not necessarily to do with the favicon.
I had same issue but solved using below solution.
<link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico" />
I used .ico file instead of .png file and thats works for me. try once.
I get same error multiple times,this error throw when u missed any small issue like wrong image path or forget to write import statement of any module/service/component.these error will shown in terminal when u running your project.After fixing these run your project
I had the exact same problem.
I advise you to take a look at your Terminal in VSCode (or the standard terminal if you launched it by there) and look for an ERROR message.
Most likely the problem isn't the favicon.ico blabla stuff but another element of your app, something in a .ts doc for example. Via Terminal you can seek for it in a better way than Chrome, that shows you this unrelated message.
I too faced same error .In my case i have done mistake in importing file
import { IUser } from 'src/app/shared/interfaces/IUser
Changed path like below is fixed error.
import { IUser } from './shared/interfaces/IUser
Cross check your import file. it might helps
I got the same error when I downloaded a new branch of the project, I just run npm install of the lastest components
I solved by created copy favicon.png from assets/icon/favicon.png to root project folder and rename it to favicon.ico , and also put it on assets/icon/favicon.ico
and also check this answer .
https://stackoverflow.com/a/63749758/8370334
Same issue here with ionic v5 and angular v10.
You may have this error when you create some error in the variables.scss file.
I was using adding a list of global variable that will be used across the app but I forgot to add a ,.
It didn't create an error while compiling...
The code was :
$color-settings: (
'primary': (
'base': #297bfd,
) // <-- Comma is missing here
'secondary': (
'base': #297bfd,
)
}
It will display the same error, I think, it breaks somehow the way ionic compile the scss.
I had the same issue after an upgrade. I solved the problem doing:
npm rebuild node-sass
Try to change the browser, I fixed this clicking on the url resource which opened firefox and then I've been able to test the app normally on Firefox

Cannot read property 'then' of undefined when installing ember-cli-coffeescript

Upon installing ember-cli i wanted to install the coffeescript add on using:
ember install ember-cli-coffeescript
as shown in the documentation but I get the error:
WARNING: Skipping npm install: package.json not found
package.json not found
Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
at Class.run (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/lib/tasks/addon-install.js:43:7)
at Class.run (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/lib/commands/install.js:39:25)
at Class.<anonymous> (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/lib/models/command.js:241:20)
at initializePromise (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:588:5)
at PromiseExt.Promise (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1076:31)
at new PromiseExt (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/lib/ext/promise.js:32:8)
at Class.validateAndRun (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/lib/models/command.js:195:12)
at /home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/lib/cli/cli.js:130:22
at tryCatch (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:538:12)
at invokeCallback (/home/daniel/.nvm/versions/node/v7.6.0/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:553:13)
I don't understand what this means. I have seen this question asked in different contexts for Angular.js but those questions are related to peoples code. This question is related to the installation itself. this is a brandnew project and install.
Any ideas?
package.json file usually in the project root, called package.json - this file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project's dependencies.
Make sure you have a proper inited Ember project. If you do not have a package.json file. Try to re-init your project using Ember init inside your project folder.
Attention: the init process may overwrite the existing files in your project. Backup if it is important.
Have you tried adding a package.json file? Easily done by running npm init

Ember-cli destDir doesn't work with app.import

When using ember cli I try do this but the file is not copied to dist:
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
destDir: 'fonts'
});
So when running the ember server I get:
version: 0.1.15
Could not find watchman, falling back to NodeWatcher for file system events
Build failed.
Path or pattern "glyphicons-halflings-regular.eot" did not match any files
Error: Path or pattern "glyphicons-halflings-regular.eot" did not match any files
what am I doing wrong?
Kindly double check wether you have your glyphicons-halflings-regular.eot is present under your bower_components folder.
If that didnt help updating your ember-cli and bootstrap to the latest version might help
npm update ember-cli
bower update bootstrap

Error when running yeoman init

I'm getting the following error when I run `yeoman init angularĂ¹, although the angular part shouldn't matter, since I got the same error:
create test/lib/angular-mocks.js
<WARN> Unable to create directory "/Users/myuserfolder/test/lib" (Error code: ENOTDIR). Use --force to continue. </WARN>
it seems to be trying to create a file in my home folder, which is weird, becuse I cd'd into a folder designated for my project. What could be going on here?
That is a known bug caused by you having a Gruntfile in your home directory.