Error: unknown package in top-level dependencies in Meteor app - javascript

I'm making a small Meteor package. It employs two other packages that are explicitly listed in its package.js. For test purposes, I add this package from local system (it's not published on Atmosphere). And I keep getting error messages after I run the app:
=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:
While selecting package versions:
error: unknown package in top-level dependencies: whoever:whatever
I even added required packages explicitly to the app but it didn't help.
The package.js:
Package.describe({
name: 'whoever:whatever',
version: '0.0.1',
summary: 'Whatever the summary is',
git: 'https://github.com/whoever/whatever',
documentation: 'README.md'
});
Package.onUse(function(api) {
api.versionsFrom('1.1.0.3');
api.use('http');
api.use('jparker:crypto-sha1', 'server');
api.use('simple:reactive-method', 'client');
api.addFiles('for-a-server.js', 'server');
api.addFiles([
'for-a-client.js',
'for-a-client.html'
], 'client');
});
What am I doing wrong? What should I look for next?

As was mentioned in your comments, it was due to a problem with symlinking. However, for googlers who come by developing their own meteor packages and also getting this message -- they need to check their env vars have $PACKAGE_DIRS defined in the terminal calling meteor to start their app.
I didn't and this caused the same problem!

Make sure to both init and update your submodules. This should work:
git submodule update --init --recursive

Can you please try and replace the single quotes with double quotes and try... something like below. Please type the quotes.
Package.describe({
name: "whoever:whatever",
version: "0.0.1",
summary: "Whatever the summary is",
git: "https://github.com/whoever/whatever",
documentation: "README.md"
});

Related

Additional loader for pdfjs-dist in react app?

I have the pdfjs-dist dependency in my react app and it isn't working - I'm not sure what I changed to cause this. I'm running node v14.16.1, npm v7.9.0, react 17.0.2, react-scripts 4.0.3, and pdfjs-dist 2.7.570. I'm getting the following error message when I run npm start:
Failed to compile.
./node_modules/pdfjs-dist/build/pdf.js 2407:53
Module parse failed: Unexpected token (2407:53)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| intent: renderingIntent,
| renderInteractiveForms: renderInteractiveForms === true,
> annotationStorage: annotationStorage?.getAll() || null
| });
| }
I've tried uninstalling and reinstalling relevant packages, as well as npm update, npm audit, and so forth. I also tried adding the worker-loader npm package but it's already a peer dependency on pdfjs-dist so it made no difference. My partner on this project has the same repo and he has no issues, so I'm sure it's something on my end. I believe it has to do with support for optional chaining, but not sure how to proceed.
Thanks!
I just stumbled upon the same issue. What I did was to revert pdfjs-dist to an earlier version (2.9.359 back to 2.6.347 in my case). It all works fine now, hope it helps someone.
A possible explanation from a similar case could be found in this other question.
try to include the package in babel-loader rule
{
test: /\.[tj]sx?$/i,
include: [
/\/node_modules\/pdfjs-dist/,`enter code here`
/\/src/,
],
loader: 'babel-loader',`enter code here`
options: {},
},
Most likely you have incorrect version of webpack. Try to use es5 build
https://github.com/mozilla/pdf.js/issues/12905
This helped me,
You need to import this lib asynchronously
let pdfjs;
(async function () {
pdfjs = await import("pdfjs-dist/build/pdf");
const pdfjsWorker = await import("pdfjs-dist/build/pdf.worker.entry");
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
})();
You Need to downgrade the package version to
("pdfjs-dist": "2.5.207")
This works fine for me.

Trouble importing from module after mix a compile

I'm in the process of re-writing my electron app with ES6, using Laravel Mix to compile the app JS and SASS. Now the main process loads up the render process fine. Once that happens my app.js loads up and that's where I have my issues. So I do:
import { remote } from 'electron';
Which causes this error in console:
Uncaught Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
Now i've tried reinstalling electron, even though electron works when the main process fires up to begin with. The line refers to this in the compiled js:
/* WEBPACK VAR INJECTION */(function(__dirname) {var fs = __webpack_require__(8)
var path = __webpack_require__(9)
var pathFile = path.join(__dirname, 'path.txt')
if (fs.existsSync(pathFile)) {
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
} else {
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
}
I'm not really sure what's going on, any advice or information would be a great help!
Thanks
Edit: I've tried running it with --verbose:
/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 3
2017-06-13 16:10:42.383 Electron Helper[47106:766924] Couldn't set selectedTextBackgroundColor from default ()
Most probably source of problem is that path.txt doesn't exists.
path.txt is generated while installing electron from npm. If you are not seeing any error while installing electron that means, errors are getting suppressed.
Troubleshoot: Check if node_modules/electron/path.txt exist. If not, then you have got a problem.
Solution:
Note: If on Windows, use native CMD instead of Git Bash
Try to install electron manually after npm install by executing following script
cd node_modules/electron && node install.js
This may take up a while, since it is going to download electron's full package.

How to setup ember engines?

I've created a standalone routable engine with ember-engines 0.4.0, ember-cli 2.10.0.
I get this error if I call the engines index route (/thingy/):
Assertion Failed: Asset manifest does not list any available bundles.
Consuming App router.js:
this.mount('thingy-frontend', { as: 'thingy', path: 'thingy' });
Engine App routes.js:
this.route('index', { path: '/' });
The engine is 'installed' via a symlink in the node_modules/ dir of the consuming ember-cli app. (See here why).
Just for fun I've tried to change the routes to test if that works ...
Consuming App router.js:
this.mount('thingy-frontend', { as: 'thingy' });
Engine App routes.js:
this.route('index', { path: 'new' });
I've called /thingy/new and got an UnrecognizedURLError. Alternative, if I call the root path, I get an Assertion Failed: Asset manifest does not list any available bundles.
Also if I place a console.log('...'); in the engines index.js, I can't see any output. Seems like it isn't loaded at all.
The setup was inspired by the official README and the official example repos.
Any idea how to fix this Ember Engines setup?
You can find the repos on GitHub:
Engine: https://github.com/phortx/ember-engines-engine
Consuming App with README: https://github.com/phortx/ember-engines-app
We could solve the issue. There have been several problems and I'll share with you what we did:
1. Add ember-engines as dependency (not just dev-dependency)
You have to addember-engines as a dependency in the package.json both for the app and the engine. So we change
the package.json to:
"dependencies": {
"ember-cli-htmlbars": "^1.0.10",
"ember-cli-babel": "^5.1.7",
"ember-data": "^2.10.0",
"ember-engines": "0.4.0"
}
Don't forget to npm install.
2. Add the actual engine to the package.json
Even if it's not public and symlinked in node_modules like in our case, you have to add the engine to the package.json.
In our case this was "thingy-frontend": "*".
Don't forget to npm install.
3. Check symlink name
In our case the symlink had the name of the engine repo instead of the actual engine name. That won't work. We changed
the symlink name to thingy-frontend (that's the name from the engines index.js).
4. Use the right resolver
You have to ensure, that both in the addon/engine.js and the app/resolver.js use the ember-resolver.
5. Failed to load asset manifest.
This is probably a bug in ember-engines. See the issue for more details: https://github.com/ember-engines/ember-engines/issues/282#issuecomment-268834293
You can workaround that issue by manually adding a <meta />-Tag to the <head> (see the GitHub issue link above)
Many thanks to Michael Donaldson!
I can't find reference to your Engine app from Consuming app package.json. I think you should add to Consuming package.json Engine app. For in-repo-addons - engines I can find in ember-engines-demo that in package.json they have:
"ember-addon": {
"paths": [
"lib/ember-chat-engine"
]
}
For not in-repo-addon, but for normal modules they have:
"dependencies": {
"ember-data": "^2.6.0",
"ember-engines": "dgeb/ember-engines#v0.2",
"ember-blog-engine": "dgeb/ember-blog-engine"
},
Notice ember-blog-engine. Here's full reference to their package.json.
However in your Consuming ember-engines-app app package.json does not list
ember-engines-engine name.
Ember processes addons from package.json lists so you have to reference your engine addon there. Otherwise you will never get any line of code from such package executed in Ember CLI environment.
Please add your ember-engines-engine to consuming app package.json.
I'd add that incompatibility could also be an issue...
As Ember Engines is experimental and being developed against the master branches of Ember and Ember-CLI, be sure that you are using compatible versions.

How to use npm modules on grunt?

Earlier when I was using node.js without grunt I had to simply write the following code to include an external module.
var express = require('express');
After I switched to grunt I am trying to use the following module qr-image.
I am stuck with the use of this module as whenever I use the following command my code breaks.
[ This is as per an official example. ]
var qr = require('../');
To Install this module in my node_modules directory I changed the package.json by adding the following dependency in
"devDependencies": {
.
.
.
"qr-image": "^2.0.0"
},
And then ran npm install command at the root directory level of my app.
Thus, Stuck with the implementation of this node.js qr-image module on grunt. Any help will be appreciated.
I believe the right way to do this is:
var qr = require('qr-image');
You can find an example in the project's readme.

Getting started with Faker.js with Meteorite

I am trying to user Faker.js with Meteorite. I have added this package:
https://atmosphere.meteor.com/package/Faker.js
I am trying to add fake users on server startup:
Meteor.startup(function () {
// code to run on server at startup
// add 100 fake tips and 10 fake articles and 50 fake users
for (var i=0; i<50; i++) {
// Accounts.createUser(Faker.Internet.userName(), Faker.Internet.email(), "1234");
}
});
but I get an error:
ReferenceError: Faker is not defined
Not sure how to fix this...
I'd recommend installing the npm package, and adding Faker as an NPM module. It's quite simple:
mrt add npm
Create a packages.json file in your project root, and add { "Faker": "0.5.11" }
mrt update
Use Faker in your code by doing Faker = Meteor.require('Faker');
Now you can use it like normal, e.g. Faker.Internet.email()
The author of Faker.js on atmosphere needs to update the package for it to work properly on Meteor 0.6.5.
In meteor 0.6.5 packages need to explicitly expose their variables. This was done so that packages variables don't conflict.
For the 'fakerjs' package the edits look pretty minor because it just interfaces the npm module.
You need to export 'Faker' in the package.on_use method in the package.js with an api.export, if you contact the author or send him a push request you could push it through faster. More details on how to expose the variables can be found in the namespacing section on the meteor docs.

Categories