I'm trying to use the npm package flag-icon-css with meteor.
I'm using sass to modify the icons path as follows:
$flag-icon-css-path: '/npm/node_modules/flag-icon-css/flags';
$flag-icon-rect-path: '/4x3';
$flag-icon-square-path: '/1x1';
#import '{}/node_modules/flag-icon-css/sass/flag-icon.scss';
but I'm stuck as i don't understand what is the correct path for the variable $flag-icon-css-path .
the question is simple : how can I access files that are in a npm package ? what is the correct path ? Do I need to export them all explicitly or something similar ?
It turns out that files from npm packages are not directly visible to the client. A solution should be to wrap the npm package in a meteor package and export what is needed to the client explicitly. In this case the solution is to use an already made package for this npm module : meteor add jss:flag-icon
NPM are packages that should be installed. It would then be able to directly adress it:
https://docs.npmjs.com/cli/install
Go in the folder using the prompt, and execute:
npm install
Related
I'm trying to deploy a cloud function on firebase. I'm successfully logged into firebase CLI from osx terminal. When I go to deploy it kicks back this error.
Oops! Something went wrong! :(
ESLint: 7.19.0
ESLint couldn't find the config "google" to extend from. Please check that the name of the config is correct.
it's because you didn't do the install
Would you like to install them now with npm? ยท No / Yes
you can try again configuring json .eslint or you can do it this way
npm install eslint-config-google --save-dev
As explained here: https://eslint.org/docs/user-guide/configuring/configuration-files#using-a-configuration-from-a-plugin
The extends property value can consist of:
plugin:
the package name (from which you can omit the prefix, for example, react is short for eslint-plugin-react)
/
the configuration name (for example, recommended)
Meaning, if you extend your config using the google plugin like this in your .eslintrc.yml:
extends:
- google
you have to install it doing:
npm install eslint-config-google --save-dev
I had the same issue, While trying to debug my error I happen to make some changes in the below code, reverting it back to this way removed the error
Please check in your .eslintrc.js ,if the below code is there or not
extends: ["eslint:recommended", "google"],
Most likely you do not have eslint installed so try to install it by running this command:
npm install eslint-config-eslint --save-dev
After making sure that ESLint is installed, you just need to initialize it by running:
eslint --init
I had this issue and resolved mine running this:
npm install eslint-config-eslint --save-dev
Most likely you didn't have eslint-config-google installed.
Once installed try running ESLint again.
I have forked an npm package on GitHub, made changes to it, and now want to install the package in my Meteor app directly from GitHub.
My package.json looks like so:
{
"dependencies": {
"semantic-ui-react": "git+https://git#github.com/nolandg/Semantic-UI-React.git",
}
}
I then run
meteor npm install
Which appears to work fine and tells me it's installed the package:
semantic-ui-react#0.61.6 (git+https://git#github.com/nolandg/Semantic-UI-React.git#f27d5c736e5de1eed0acf7769f18caee57578526)
And indeed the package appears in the node_modules folder. But when I try to start my Meteor app, I get this error:
Cannot set property '/my-website/node_modules/semantic-ui-react/package.json' of undefined
at Resolver._resolvePkgJsonMain (/tools/isobuild/resolver.js:320:9)
Has anyone successfully install an npm package in a Meteor app directly from GitHub? I can't figure this one out. Thanks!
Meteor version: 1.4.2.3
The main reason why the package does not work when fetching from git is because it is not configured to work that way. This is not a Meteor specific problem, but a problem that a JS developer may face sometimes.
For this particular case there are two problems:
The whitelist files field in package.json only contains src and dist folder. That means when you fetch it by npm almost all config files needed to build the code are gone.
Code for this package requies to be built in order to work with your code. This is done when the author publish it to npm, but you fetch it directly from github so this step is undone.
Because you already folked and modified the package, so let modify the package.json as below (remove all the comments I added them to give you some explanation), push it to github, and fetch it again by npm:
// remove the "files" field
// ...
"scripts": {
// this script is used to build the package
"postinstall": "postinstall-build dist \"npm run build:commonjs\""
// ...
},
"dependencies": {
// this helps build the package
"postinstall-build": "^2.1.3"
},
// ...
Packages are not usually installed from github, they are published, which means that many versions of a package are available, you can choose which one you get. I'm not sure if what you are doing is possible, but it's certainly inadvisable.
If you want to make changes to a github package, you can download the it to your local machine and do npm link, so that it uses your local package instead of the one on npm. Read more about it at https://docs.npmjs.com/cli/link
Why do you not use simple command?
meteor npm install https://github.com/nolandg/Semantic-UI-React.git
I did:
meteor create test
cd test
meteor npm install
meteor add react react-dom
meteor npm install https://github.com/nolandg/Semantic-UI-React.git
meteor
And no errors (-:
If I'm setting up a project and running npm install -abc xyz, can I run another npm install in another terminal instance, for the same project, whilst this is still running?
Thanks!
You can install multiple packages with a single command like this:
npm install --save package1 package2 package3 ...
EDIT:
Installing packages separately, while theoretically possible, could create problems. When an install command is issued, npm looks up existing modules and downloads missing packages into a staging folder .staging inside node_modules. Once downloaded it copies the packages into the node_modules sub-folder (and removes .staging).
In npm2, modules had their own dependencies stored underneath themselves like this:
node_modules
- dependencyA
- node_modules
- dependencyC
- dependencyB
- node_modules
- dependencyC
Notice how dependency A and B both rely on C. If C is the same version in both cases, it would use twice the space.
In npm3, dependencies are flattened like this:
node_modules
- dependencyA
- dependencyB
- dependencyC
If for some reason an older version is used in a dependency, it follows the npm2 convention for that module.
I'd stick with the intended use of npm and use the multiple install functionality.
I simply use the following
example
npm i daterangepicker select2
There isn't a clear guide on how to install Phantom for Meteor, so I decided to ask a question to clarify things.
Do you have to install phantom binary in /usr/local/bin/? I downloaded a compiled phantomjs from the official website and placed inside the above path. I can run phantomjs from anywhere now because it's added to path.
In addition to 1, do you also have to install it from meteor npm? I followed this to install "phantomjs": "1.9.13" as a npm package inside my Meteor app. It gets confusing from here because the binary from the official website is v2.0.0 while the npm package is 1.9.13. Do I need to install both?
Because of the confusion in 2, I removed /usr/local/bin/phantomjs but then I can't run $phantomjs anywhere because I don't have anything in PATH.
My ultimate goal is to get spiderable working. What should I do?
Okay, the problem was the compiled phantomjs binary from the official webpage cannot be used right away in the latest Mac OS, but you have to unpack it first. To run spiderable package you don't need to do anything other than placing the binary file phantomjs inside your local path /usr/bin/local/. You can test this by running $phantomjs in your terminal. If you see phantomjs not found then you haven't installed it. If you see an error killed 9 then you have the same problem as mine, and you can solve it by following this.
You do not need the meteorhacks:npm package.
You can do this in two ways:
Method 1:
If you'd like to be able to use PhantomJS via your Meteor app, you would need to use the Meteorhacks NPM package and use the latest NPM version 1.9.16 I believe.
After that, you can edit your packages.json file to add "phantomjs": "1.9.16", and then reference it via var phantomjs = Meteor.npmRequire('phantomjs');
Method 2:
Alternatively, you can use the smart package for Meteor PhantomJS and give that a shot.
I personally feel like Method 1 is a better option, as that worked for me. I needed PhantomJS for an app, and that solution worked for me. I haven't tried Method 2 so I can't speak for it, but it looks promising as well.
Give them a shot, and let me know how it goes. Hope that helps!
Here is a phantomjs wrapper package from atmosphere: https://atmospherejs.com/gadicohen/phantomjs
More importantly here is the spiderable package:
https://atmospherejs.com/meteor/spiderable
I couldn't really answer the questions but more so point ya in a direction that I hope will solve your problem :)
In the terminal:
$ meteor npm install --save phantomjs
In your_meteor_app/server/main.js file (or wherever, provided it's server-side)
import phantom from 'phantom'
Just use npm:
//Global effect on your machine
npm install -g phantomjs
//Test if installed
npm list -g
//Test spiderable working correctly
Test spiderable
I am working on a meteor project. Have to use natural package for natural language facility. I installed that using 'npm install natural'. But when ran the project, got error as 'ReferenceError: require is not defined'.
Added this line: var abc=Meteor.require('natural'); in the file in which have to use it. But when I am running the project, it is showing error as:=> Started proxy.
=> Meteor 0.8.1.3 is available. Update this project with 'meteor update'.
=> Started MongoDB.
=> Errors prevented startup:
While building package `router`:
error: no such package: 'page-js-ie-support'
error: no such package: 'HTML5-History-API'
-- When tried to install the above listed missing packages, showing error as:
smart.json changed.. installing from smart.json, I got the following error after successfully installing various packages like natural, iron-router, paginated-subscription, router, accounts-ui-bootstrap-dropdown, spin. But after that showing following error. Why so?
/usr/local/lib/node_modules/meteorite/lib/dependencies/package.js:106
throw('Could not locate package.js within path ' + self.source.packagePa
^
Could not locate package.js within path /home/priya/.meteorite/packages/natural/NaturalNode/natural/d541ca394659521498ed36a7f6e03fef93163e53
-- The packages in my project are: I don't understand here as router package is already listed then why showing error while running the project.??
meteor list --using
standard-app-packages
bootstrap
router
accounts-ui-bootstrap-dropdown
accounts-password
spin
paginated-subscription
email
insecure
iron-router
npm
Please guide me in this direction. This error is becoming a recursive kind of error. Have broke my head in this problem but still stuck. Thanks in advance
You have a package called Natural (not sure which) which isn't built to the correct packages specifications or has been modified somehow.
This can't be fixed that easily, you would have to contact the author of the package to fix it or modify it yourself. I can't find NaturalNode on atmosphere so its likely a custom package.
You might want to make the rest of your app work to debug fixing it though. To do that you need to remove this package
Remove the files and folders in ~/.meteorite/packages
Look through your packages smart.json and remove the offending package (natural). and run mrt update. And remove the rest of the code in your app relating to natural that might stop your app booting up.
From what it looks like you've cloned https://github.com/NaturalNode/natural into meteorite somehow. You would have to look at how to build a package for meteor.
The files you have used are an npm module and don't just work with meteor if you copy the files in. You have to make a compatible meteorite package for it to work. Or use meteor-npm to use the npm module in your app directly.
This project may also help you get started as an example of how to make a wrapper for an npm module to use with meteor