Uncaught Error: Could not find module `ember-qunit`. Odd out-of-the-box ember-cli behavior - ember.js

I believe I may have an environment issue here, but I'm quite stuck as to what I can to do resolve it. I created an ember-cli project, committed it to git, added a few things. I ran the typical npm install && bower install commands and tried ember s.
Although the site loads fine, when I browsed to the http://localhost:4200/tests/ to ensure qunit was up and running, I had a few errors.
Uncaught Error: Could not find module `ember-qunit` imported from `ember-project/tests/test-helper
Uncaught Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".
Immediately this raised a red flag, as I have created several ember projects before and not run into similar issues. I had my partners (I'm in school) checkout the project, run the npm install && bower install && ember s and the qunit module worked fine for them!
I've tried to git clone a new repo several times, I've even went so far as to uninstall node and bower completely, but no matter what I try I cannot seem to pull up a normal /tests checkout.
My partners were both running VMs - Ubuntu and Debian, while I'm on a mac, but that seems like it shouldn't be too big of an issue, especially since I created the project!
I've looked several places for this (here, here, and here), but I cannot seem to come to a conclusion which works for me.
I do have an identical bower.json as the rest of my group. I've included the picture below of my file structure, my bower.json, and my tests/index.html.
screenshot
Here are some environment stats:
ember version: 1.13.13
node: 5.0.0
os: darwin x64
bower: 1.7.1
One thing that I did notice is a difference when I do this to see npm's version, but I'm not sure if that matters or not.
ember -v
npm: 2.14.10
npm -v
npm: 3.5.2

It appears to be a regression from the work in ember-cli beta. You can track the progress here https://github.com/ember-cli/ember-cli/issues/5411.
For now, you can add
app.import('bower_components/qunit/qunit/qunit.js');
app.import('bower_components/ember-qunit/ember-qunit.amd.js');
to ember-cli-build.js as a workaround.

Related

Ember build issue: "Cannot use the decorators and decorators-legacy plugin together"

I have recently encountered an issue with building my ember project with bitbucket pipelines:
+ ember build --environment="production"
Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Building
Environment: production
cleaning up
cleaning up...
Build Error (broccoli-persistent-filter:Babel > [Babel: ember-data]) in ember-data/adapters/json-api.js
Cannot use the decorators and decorators-legacy plugin together
I am currently using ember-cli version 3.8.1.
The issue occurs with all build environments, not just production.
What baffles me is that no new npm package or ember addon was added between last successful build and the ones that have been failing since - and now if I re-run the successful build, that will also fail.
I have gone back in the commit history to a commit that worked, then fast-forward into the present step-by-step - always deleting the node_modules and reinstalling the packages. It always works locally, but it will always fail when the pipeline is run.
I have also tried updating my docker image.
I have already gone through and tried the solutions listed here - but it seems like they have already been addressed in version 3.8.1.
Also, if it is any help, this is my bitbucket-pipelines.yml:
pipelines:
branches:
master:
- step:
name: Building Ember Project
script:
- npm install
- npm install firebase-tools
- ember build --environment="production"
- step:
trigger: manual
deployment: production
name: Deploy to Production
script:
- firebase use prod
- firebase deploy --non-interactive --token ${FIREBASE_TOKEN}
Thank you all in advance!
This sounds like a sub-dependency changing on the fly under the hood. Do you have an npm or yarn lockfile commited as part of your repo? Lockfiles are specifically designed to keep from hitting snags like this
I have gone through the below errors,
Build error : “Cannot use the decorators and decorators-legacy plugin together”
Build error: 'relationshipStateFor' is not exported by -private\system\record-data-for.js
On browser got Expected store.createRecordDataFor to be implemented but it wasn't.
Reason for the above error is with ember-data addon and mismatch in ember-cli version installed for my project.
In your package.json, You might have defined ember-cli version( "ember-cli": "^3.11.0",) with ^ symbol this means it will install latest version which is less than the 4.0.0. So your ember-cli in node_modules might be installed to the latest version.
The above mentioned error is caused by the ember-cli version which was installed and pointed to 3.15.0. So I have removed the ^ and updated "ember-cli": "3.11.0", and removed node_modules and did npm install that solves the above problem.

How to create a ember version specific project?

When i use,
ember new projname
project is getting created with 2.7.0 ember version. I want to create a older version ember project. What i should use? [i checked options that can be used with new command, but none helps for this.]
Here's what I ended up doing:
create a new directory for my project and cd inside of it
npm init (enter through some bogus details, doesn't matter, we're going to erase soon)
npm install --save-dev ember-cli#desired.version
delete package.json and package-lock.json
ember new app
This got me a node_modules folder with the desired version of ember, and then also allowed me to use the ember cli to generate a project. It will create a folder with the name of the app, of course, and you can safely delete the node_modules folder in the app's parent directory.
This feels like a little bit of a round-about way of doing things, but it worked, and it seemed easier than trying to mess with my global versions.
Hope this helps someone out!
Ember new will create project at the most current version installed on your system.
There are 2 ways around this.
Install an older version of ember-cli globally for the desired version. The benefit would be that you create a new app at the desired version from the get go:
(change #2.11.0 to the desired version from https://github.com/emberjs/ember.js/releases)
npm uninstall -g ember-cli
npm cache clean
npm install -g ember-cli#2.11.0
Keep the current ember-cli version and then downgrade by changing the ember value in package.json :
(this will work for small version changes, not major changes)
you will need to re init your ember app (change 2.11.0 to what you need from https://github.com/emberjs/ember.js/releases)
rm -rf node_modules dist tmp
npm install --save-dev ember-cli#2.11.0
ember init
Node.js is required with every Ember installation and you have to check which version of node is required for the desired version of Ember you want to install. Most likely itll work well with the version currently installed.
you can download the latest (LTS) from: https://nodejs.org/en/
or older versions from: https://nodejs.org/dist/
OSx for example https://nodejs.org/dist/v4.7.0/node-v4.7.0-linux-x64.tar.gz
results

Is there an easier way to debug ember addons

I have been just starting out with ember addon and one of the difficulty I am facing is to debug it. I have a separate repo for my addon(lets name it my-addon for now), and everytime I make any change, I have to
1) commit it
2) push the changes
3) go to consuming app and then re install the app from git(atleast re-run npm install git:address so I get the latest changes)
4) run ember g my-addon (because I am in older cli)
5) do build
6) and check if things are working
This process is kinda tedious, I was wondering if I can place the addon(all of it) within the consuming app itself, atleast in the dev phase so I can just build my ember app and test the addon in the consuming app itself, and once I feel good about, push it to my local git repo.
Any thoughts or approach on how you folks do it - or may be I am just missing out something and doing it wrong!
Thanks,
Dee
If you use ember-cli you can link your local addon in the consuming app. You can find all details in the user guide
Note that watchman doesn't observe local addon symlinked (there are couple of issues opened both on ember-cli and watchman). I've resolved removing watchman falling back to NodeWatcher (I'm on mac)
I am pretty sure the solution provided by #GUL must work too, but what worked for me was:
1) in the consuming dev app, I created a folder called addons and placed all my addon code there
2) in consuming dev app, in package.json I added :
"ember-addon": {
"paths": [
"addons/ember-chart"
]
}
and that worked for me!
The top answer is best here. I just wanted to offer an alternative that is useful in certain situations. npm pack at root of in development addon. Then cd back to parent project. npm install ../ember-composable-helpers-2.2.0.tgz. And then check if things are working.
npm pack will create a tarball as if published on npm.

NPM repo missing file

I have a git repo for an Ember Addon:
https://github.com/lifegadget/ui-responsive-toolbelt
It passes all unit tests. It has been published to npm as ui-responsive-toolbelt. I have used npm's "link" functionality to test locally that this "addon" (in Ember parlance) works fine in consuming application when included in the package.json file as a dependency.
Surprisingly, and I'm completely flummoxed on this, when npm installs this dependency into an Ember project directory it brings across a vast majority of the files without complaining. From NPM's perspective it appears to be a clean install. Unfortunately an addon depends heavily on it's "entry point" which is the index.js in the root directory of the repo. I have very clearly included this file in the repo but for some reason it is not being brough over!
I have tried this on two computers and three Ember projects and all have the same outcome. Please help!
the error message I get from Ember-CLI when I try to start the server with ember serve is:
The package ui-responsive-toolbelt is not a properly formatted package, we have used a fallback lookup to resolve it at /path/to/project/node_modules/ui-responsive-toolbelt. This is generally caused by an addon not having a main entry point (or index.js).
This message is repeated twice and then I get:
The ui-responsive-toolbelt addon could not be found at /path/to/project/node_modules/ui-list/node_modules/ui-responsive-toolbelt.
I confirmed that your repo looks fine
npm install ui-responsive-toolbelt does not download the index file
So the problem is that npm publish is not working properly. There is a bug filled for that. https://github.com/npm/npm/issues/5082
What you can do is publish again your addon using a recent npm version (or play with older versions) until you see that the index file is added too.

Can't "ember server" but "npm start" works

Although I successfully installed ember-cli, I cannot run ember server. It said -bash: ember: command not found. But when I ran npm start, that worked.
According to the package.json file, npm start is referring to ember server.
But why didn't ember server work?
The way I fixed this problem is by running ember init in the repo, and let it override all the testing related files and skip all the files related to the project, like routes/app.js.
Oh, Yeah~
Based on your comments, it sounds like you may have installed npm or another part of the node toolchain with sudo. Here are some common ways to install the toolchain--I can say from experience that avoiding using sudo in package managers (and everything possible) is often the way to go.
Hope this helps--let us know if it was something else.