Error: Cannot resolve module 'apply' webpack angular2 - node.js

I am not really sure how I got into this pickle.. I uninstalled my global webpack and reinstalled it locally to dockerize my project. Then I got a trail of errors, resolved the ones I could and I'm left with this
http://puu.sh/orazd/b8a85ac5c6.png
I don't use any module called apply, most certainly not in every file

I had tried resolveLoader previously
and it had worked for me.
My configuration is as follows:
resolveLoader: {
modulesDirectories: [
'/users/path/a/node_modules'
]
},
Hope this helps.

Though not sure, I think maybe something wrong, like conflicts, in the typings folder. Would you try to remove typings folder and run npm install again.

The answer turned out to be
silly enough.. the error was a little misleading but.

Related

Problems exporting a functional component in a ReactJS Module

I'm having problems importing my functional component BusinessCard (declared here https://github.com/HenryFBP/react-business-card-hfbp/blob/master/src/BusinessCard.tsx#L20)
into a different project (here https://github.com/HenryFBP/personal-website-react/blob/master/src/pages/PageContact.tsx#L3).
I used npm link react-business-card-hfbp, and I can see the symlinked folder, but I must be doing the export incorrectly or don't understand package.json.
I have also tried installing from https://www.npmjs.com/package/react-business-card-hfbp/ but that does not seem to work either.
The error (below) from webpack is Module '"react-business-card-hfbp"' has no exported member 'BusinessCard'.. I tried so many different combinations, edited package.json quite a lot, but I am stuck on this.
I'm sure the answer is simple, I just don't have enough experience with Node Modules to understand what is going on.
Thanks so much <3
I fixed it! With the help of a kind person on "Reactiflux" Discord server.
TL;DR: I was not compiling it into a module correctly. I should have used parcel to compile it into a module. I thought that TypeScript could be included in modules - this is apparently not correct, you must somehow turn it all into JavaScript first.
Working code:
npm run build
npm publish
Working package.json:
https://github.com/HenryFBP/react-business-card-hfbp/blob/master/package.json#L42

Using localForage and angular-localForage with Browserify causing errors with require statements

I am attempting to install localForage into a node.js application (with Angular) and Browserify.
Here is a link to the localForage documentation
It appears that using localForage and angular-localForage causes a problem with browserify based around the use of 'require'
If I require the localforage.js file in the src file I get the following error:
Warning: module "promise" not found from "/Users/mgayhart/Sites/epson- receipts/bower_components/localforage/src/localforage.js" Use --force to continue.
If I require the localforage.js file in the dist file, I get the following error:
Warning: module "./drivers/indexeddb" not found from "/Users/mgayhart/Sites/epson- receipts/bower_components/localforage/dist/localforage.js" Use --force to continue.
Anyone know of a workaround to be able to move forward with these libraries?
There is an issue on github with this problem: https://github.com/ocombe/angular-localForage/issues/26
I'll be working on it soon, you can subscribe to the github notifs on this issue to know when it's fixed !
For me installing it through bower and using it with browserify-shim worked. So in package.json:
"browser": {
"localforage":"./src/lib/vendor/localforage/dist/localforage.min.js"
},
"browserify-shim": {
"localforage":"localforage"
}
And to expose it as an angular-service (if you don't want to use angular-localforage):
app.factory "localforage",-> require 'localforage'
I've just been having this issue myself tonight, but I think I found a fix.
Instead of trying to get the bower modules to work with browserify, why not just use npm like its made for?
npm install localforage
and then when you use require you don't have to give it the path
but it still didn't work for me until I copied the folder:
localforage/src/drivers TO localforage/dist/drivers
Then it found all the dependencies and worked like a champ!
Alternatively if you must use bower you could try to use the debowerify tranform w/ gulp:
https://github.com/eugeneware/debowerify

npm installs dependencies with complete readme in a package.json -- invalid json results

Today I upgraded npm and node. I'm at 1.4.9 and 0.10.28, respectively. (OSX 10.9.2.)
Since then, it seems that npm install is writing "bad" package.json files for all of my dependencies.
Specifically, it is putting sevaral fields into the files that do not seem to be present in the source repo's package.json.
Like this example. I have about 40 dev dependencies and they all have this junk (not to pick on gulp, I just happened to grab it for this example):
"readme": "<p align=\"center\">\n <a href=\"http...",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/gulpjs/gulp/issues"
},
"_id": "gulp#3.6.2",
"_shasum": "ea6b33d768db4a22294fa6339afb61842f5e6fb5",
"_from": "gulp#~3.6.2",
"_resolved": "https://registry.npmjs.org/gulp/-/gulp-3.6.2.tgz"
These are on the root of the package.json object. Note, I've abbreviated the readme -- it's an entire html-ized version of the readme, and in many of the files it's not properly escaped and thus makes package.json invalid and unusable.
Obviously this leaves me dead in the water. My questions are "what did I do"? And how do I undo it? Did I wind up with a version of NPM that I shouldn't have? Could there be something else about my project, my node install, or the rest of my environment that might cause this? I do have nave and a version of node in the 0.11 family, but that's not active and hasn't been in recent history -- could npm update -g npm have discovered that I have 0.11 in a different directory and jumped me into territory to which I should not have gone? If so, how to I go backward? I've tried npm installing npm back down into earlier versions but npm still reports the higher version number as if my install didn't happen, and I can't quite figure out what version I'm supposed to have, anyway.
What I've tried so far -- reinstalling node and npm, wiping out my node_modules for the project, and npm cache clean. Nothing seems to have any effect. I'd be happy to answer any questions that I can about my environment that might help me resolve this.
TIA!
I just poked my way somewhat blindly into a solution.
(although I suspect it didn't matter, I upgraded to the master branch code of npm)
I believe that I fixed this by experimenting with setting long = false in my .npmrc file. No more readmes in package.json files! :)
Aside: the package.json content that I see is quite foreign to me in its arrangement, but I guess that may be a function of being on a newer version.
At the very least, the package.json is now valid json and life is better again. I'm not going to accept this, my own answer, just yet because I hope someone might be able to tell me why I needed to do this. This is an override in my .npmrc file as far as I understand it, so it seems bizarre that out of the blue I needed to add this override by hand based on no documentation....
I'll accept an answer that points me to an explanation of what happened or of what might have happened, if there is such an answer! If none are forthcoming, I'll just accept my own answer so that the SO question loop is closed. Thanks!

Nodeunit with grunt can't find module 'tap'

So, armed with this tutorial, I decided to add some unit testing to my node.js app. My gruntfile seems to be OK, and when I type grunt nodeunit my only test runs just fine, but after that, it crashes with error Fatal error: Cannot find module 'tap':
$> grunt nodeunit
Running "nodeunit:all" (nodeunit) task
Testing db.test.js
.OK
Fatal error: Cannot find module 'tap'
I didn't know anything about this module, but after googliing it up, it seemed that it's something nodeunit would require. And indeed, there it is: $MY_NODE_APP/node_modules/nodeunit/node_modules/tap exists, and when I launch node in $MY_NODE_APP/node_modules/nodeunit and type require('tap') in interactive console, I get some object with a lot of stuff that gives me an impression that it works as it should.
So, the obvious question: why do I get this error, and how can I fix it?
Gruntfile:
module.exports = function(grunt) {
grunt.initConfig({
nodeunit: {
all: ['./**/*.test.js']
}
});
grunt.loadNpmTasks('grunt-contrib-nodeunit');
};
Update: Installed tap to my project, but it didn't help too.
I landed on this question and have since resolved my own issue. I'll post my resolution as it might be helpful to someone else:
First the similarities:
I was just getting my Gulp scripts setup, and I got this error when running my tests:
Fatal error: Cannot find module 'tap'
Which didn't make sense because I wasn't using that library!
How I resolved:
Turns out my paths were all kind of screwed up in my gulpfile.js. Therefore I was trying to unit test all of the modules in my node_modules folder!
Here's the new path:
paths: {
mocha: [
'**/*.test.js',
'!node_modules/**/*.js'
]
}
The issue for me was that I was inadvertently running the tests within the node_modules directory. My npm test was mocha **/*.test.js and when I changed it to mocha src/**/*.test.js all of a sudden the message went away. Makes sense really.
I have solved the problem by adding another '*' right after "mocha" it is related to the folder's path so it may also fix the problem in other cases.
I solved the issue (well, this issue — it wasn't the last one) by installing the tap module manually.

node module install error (Node.js)

I can't install any node.js module without the follwing errors popping up. The error codes refer to the package.json file. Any idea why this would be happening would be hugely appreciated.
Those are not errors, they are just warnings. Everything is as it should be, though the module owners should probably clean up their package.json files.
Those are not errors, are warnings.
As I already stated in the same question right here, this is just a new check added as of NPM 1.2.20.
There are so much packages in NPM that still lack the repository field in their package.json file.

Resources