Meteor can't find local npm module - meteor

I am developing some npm packages parallel to my Meteor application.
The first one is finished and it's tests and build are running without errors.
I want to install my package (mypackage) in my meteor project (myproject) by using a local path:
cd myproject
meteor npm install --save ../lib/mypackage
Note, that it exists in a lib folder outside of the Meteor project. This seems to install the package, as it outputs
+ mypackage#0.0.1
added 1 package in 12.475s
When looking into the node_modules folder it also exists, but it only as a (soft?) link:
cd node_modules && ls -la | grep mypackage
lrwxr-xr-x 1 user group 22 26 Jan 11:02 mypackage -> ../../lib/mypackage
Here comes the problem: When running my project or my tests I get an error for the following line:
import { SomeClass } from 'mypackage';
The error is:
W20180126-11:07:08.933(1)? (STDERR) Error: Cannot find module 'mypackage'
W20180126-11:07:08.933(1)? (STDERR) at Function.Module._resolveFilename (module.js:536:15)
W20180126-11:07:08.933(1)? (STDERR) at Function.resolve (internal/module.js:18:19)
W20180126-11:07:08.933(1)? (STDERR) at Object.require (/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/meteor-test-runqigr0c.jhjdg/.meteor/local/build/programs/server/boot.js:287:32)
W20180126-11:07:08.934(1)? (STDERR) at makeInstallerOptions.fallback (packages/modules-runtime.js:651:18)
W20180126-11:07:08.934(1)? (STDERR) at require (packages/modules-runtime.js:244:16)
W20180126-11:07:08.934(1)? (STDERR) at collections.tests.js (imports/startup/both/collections.tests.js:1:306)
W20180126-11:07:08.935(1)? (STDERR) at fileEvaluate (packages/modules-runtime.js:343:9)
W20180126-11:07:08.935(1)? (STDERR) at require (packages/modules-runtime.js:238:16)
W20180126-11:07:08.935(1)? (STDERR) at /private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/meteor-test-runqigr0c.jhjdg/.meteor/local/build/programs/server/app/app.js:7933:1
W20180126-11:07:08.935(1)? (STDERR) at infos.forEach.info (/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/meteor-test-runqigr0c.jhjdg/.meteor/local/build/programs/server/boot.js:414:13)
I tried to resolve this using absolute paths but it did not help. Has somebody experience with this issue?

There is a special npm feature for doing this called npm link
It allows you to use your local package in preference over the published version. You will first need to an npm link inside the source of the package itself (to make it available)
And then within your project you do it again, but naming the package, eg npm link my-package
More information here:
https://docs.npmjs.com/cli/link

I recently worked with mui-rte npm package, I needed to make some changes so forked it and try to install locally. Here are steps to make it works.
Go to mui-rte local folder, run npm run build
Inside mui-rte folder, run npm link
Go to the project folder, run npm link mui-rte
It works. Thanks #Mikkel for the link. #Jankapunkt I'm using Meteor too.

Related

Meteor (1.4.1) checkout not able to run on code ship server

I am using code ship to run some tests and deploy to galaxy.
Right now the setup works by running meteor from a git checkout. The following is the setup script:
git clone https://github.com/meteor/meteor.git ~/meteor
cd ~/meteor && git reset --hard 365c765 && cd -
export PATH=~/meteor/:$PATH
meteor npm install
Right now I cannot get passed the meteor npm install command without throwing an error. The error is the following:
It's the first time you've run Meteor from a git checkout.
I will download a kit containing all of Meteor's dependencies.
######################################################################## 100.0%
Installed dependency kit v4.2.9 in dev_bundle.
/home/rof/meteor/tools/cli/dev-bundle.js:55
return getDevBundleForRelease(release).then(function (devBundleDir) {
^
TypeError: Cannot read property 'then' of null
at getDevBundleDir (/home/rof/meteor/tools/cli/dev-bundle.js:55:41)
at Object.<anonymous> (/home/rof/meteor/tools/cli/dev-bundle.js:205:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.getDevBundle (/home/rof/meteor/tools/cli/dev-bundle-bin-helpers.js:6:10)
at getChildProcess (/home/rof/meteor/tools/cli/dev-bundle-bin-commands.js:28:13)
What do I need to do in order for the meteor install to work on code ship?
There's a script available at https://github.com/codeship/scripts/blob/master/packages/meteor.sh that should take care of the installation.
Include it in your setup steps by adding the following command
curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/meteor.sh | bash -s
If this doesn't work for your project, please open a new issue on the repository or reach out to Codeship Support via https://helpdesk.codeship.com and we'll take a look.

Use apollo stack with meteor

i'm trying to use apollp stack with my meteor project. i used
meteor add apollo
meteor npm install --save apollo-client apollo-server express
to install apollo stack but when i execute meteor to run my project it gives errors
/home/xxxxxx/Example/crud/.meteor/local/build/programs/server/packages/modules.js:97872
const graphql_1 = require('graphql');
^^^^^
SyntaxError: Use of const in strict mode.
at/home/xxxxxx/Example/crud/.meteor/local/build/programs/server/boot.js:292:30
at Array.forEach (native)
at Function._.each._.forEach (/home/xxxxxxx/.meteor/packages/meteor-tool/.1.3.4_1.1wjluqr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
Any ideas about what happened here ??
I'm trying to do the same thing. I think I can get you to the next step. Just add a couple of things to your npm install:
meteor npm install --save apollo-client apollo-server#^0.1.1 express graphql
I've put in a PR to add graphql to the npm install in the docs. Also, apollo-server has recently updated to 0.2, but meteor-integration is still working on it - the #^0.1.1 will not be needed when this is resolved. I'm still having some issues, so this may not get you all the way there, but it resolved this error for me.

Meteor error EACCES, permission denied '/var/www/'

I am building a meteor app that uses manuel:reactivearray package for making reactive arrays.
I do not know what happened but as i installed the package wrote some sample code and waited for the update i am getting this error:
/home/leocrawf/.meteor/packages/meteor- tool/.1.1.10.1l2mozl++os.linux.x86_32+web.browser+web.cordova/mt-os.linux.x86_32/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20160126-16:57:19.116(-5)? (STDERR) throw(ex);
W20160126-16:57:19.116(-5)? (STDERR) ^
W20160126-16:57:19.371(-5)? (STDERR) Error: EACCES, permission denied '/var/www/
I have done every thing from delete the build folder, delete the meteor folder and added all the packages anew excepting manuel:reactivearray but still the same error. Development is now halted until i get rid of this. Any idea how to remove this problem? I am using meteor 1.2.1.
Check the file permissions on that folder and it's sub folders (both user and group) using ls -la on the command line. The user should map to the current user you are running meteor as, which in this case appears to be leocrawf. If you plan on running meteor in /var/www as leocrawf, then you would need to run this command to change the file permissions to that user:
chown -R leocrawf /var/www
Personally I set up explicit users specifically for each instance, so I have a user called DEV who uses the /var/www/DEV folder to run meteor.

What's the right way to install and use bower in Meteor?

In a meteor project, I want to pull a few frontend packages. bower can pull many frontend dependencies which are not yet available using meteor add. In many cases, when the meteor packages are available, their versions are lagging behind the official ones, sometimes too behind to consider.
Being a bit of a Meteor newb I've tried to install bower (the most recent meteor bower package I could find):
$ meteor add bozhao:bower
but then, when I run the meteor server it crashes:
W20160110-15:37:57.997(2)? (STDERR) /Users/igal/.meteor/packages/meteor-tool/.1.1.10.7bj3ks++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20160110-15:37:57.998(2)? (STDERR) throw(ex);
W20160110-15:37:57.998(2)? (STDERR) ^
W20160110-15:37:57.998(2)? (STDERR) ReferenceError: window is not defined
W20160110-15:37:57.998(2)? (STDERR) at bower_components/leaflet/dist/leaflet-src.js:526:1
Question is:
What's the best strategy to install bower and use it in a meteor project? An acceptable answer may show the flow for correctly installing bower, then the leaflet package and it's leaflet.markercluster extension
Sep 27th 2016 edit
The meteor community switched to npm, thus using bower is no longer required. Simply do npm install <package> and import <package> in your client-side code, and you can start using the component!
meteor search bower turns up a few hits, which I haven't taken the time to compare in any depth. I went with mquandalle:bower as I found it recommended here. Perusing the doc, here is what worked for me:
npm install -g bower # If not already done
meteor add mquandalle:bower
echo '{ "directory": ".meteor/local/bower" }' > .bowerrc # If you use bower install --save
Then create a bower.json file at the top of the project tree that reads like this:
{
"name": "MyApp",
"version": "0.0.1",
"dependencies": {
"leaflet": ">0",
"leaflet.markercluster": ">0"
},
"private": true
}
Re-run your app with meteor run and presto, the stylesheets and JavaScript of your modules are embedded into your page without even having to edit the <head>.

Installing natural package in a meteor application

For having natural language processing facility. Have added natural node package in my application using "npm install natural". But after installation while running the application using "sudo meteor", got some error about ""ReferenceError: require is not defined"". After googling found that need to do following steps:
1) Remove node_modules on the top of the root of the application (Done this part)
2) Added "natural": "0.1.27" in packages.json file also
3) Install npm using ""mrt add npm"". But getting following error after installing it in the application, while using ""sudo meteor"".
=> Meteor 0.8.1.3 is available. Update this project with 'meteor update'.
Initializing mongo database... this may take a moment.
npm ERR! missing: rimraf#2.x, required by meteor-npm#0.1.10
npm ERR! missing: mkdirp#0.3.x, required by meteor-npm#0.1.10
npm ERR! not ok code 0
=> Errors prevented startup:
While building package router:
error: no such package: 'ui'
While building package npm:
error: couldn't read npm version lock information
=> Your application has errors. Waiting for file change.
Any pointers what should be done. Not getting anything, this error taking my whole time. Thanks in advance
To use NPM packages within your meteor application you need to first install meteor-npm
mrt add npm
You then have to add a packages.json file at the root of your project like so;
{
"natural": "0.1.27"
}
When this file changes, meteor will automatically update its dependencies.
You can then use var natural = Meteor.require("natural")

Resources