Im trying to upload a node.js app into cloud foundry, im not going to use Express Framework, but when doing "vcm push" Im getting this error.
Uploading Application:
No such file or directory - /Users/jtomasrl/Code/node/pronto/node_modules/express
here is my package.json
{
"name": "karaoke-api",
"version": "0.0.1",
"dependencies": {
"pronto": "*",
"pronto-mongodb": "*"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
Just for the sake of providing an "answer", when this situation does arise, it's worth emptying node_modules/.bin or even removing node_modules itself and re-installing modules with;
npm install
Related
I've had a discord bot for a few weeks and everything has been working perfectly. Today I added a command on my git repository and suddenly heroku showed me this error:
Error: Cannot find module 'discord.js'
I didn't change anything in the main bot code nor in the package.json file. I removed the new command I added and pushed the new changes again, and still got the same error.
I tried to reinstall discord.js with npm install discord.js --save and updated the package.json with the new version. Still nothing.
The bot works if I run it locally, and it also works if I roll back to the last working build on Heroku.
My bot.js code to load the library:
const Discord = require("discord.js");
My package.json file:
{
"name": "redacted",
"description": "redacted",
"version": "1.0.0",
"main": "bot.js",
"scripts": {
"start": "node bot.js"
},
"dependencies": {
"discord.js": "^11.5.1",
"request": "2.81.0"
}
}
I don't know what to do because the code is exactly the same as the previous versions. I don't understand why I'm getting this error.
I believe the error may lie in your package.json file, you are a missing a few key things:
You must include the versions to use for both node and npm (I'd recommend using the latest):
"engines": {
"node": "12.14.1",
"npm": "6.13.4"
},
Next you need to also define your git repository like so:
"repository": {
"type": "git",
"url": "git+link"
},
As well make sure in your Procfile you have:
worker: npm start
In your requirements.txt make sure to have:
npm install discord.js
You can read more on hosting your discord.js bot on Heroku here.
I hope you can help me . i'm fairly new to node and am building my first node app.
I have built out an app in node.js. It works fine and as expected when running locally.
When trying to run it on our internal production server I get an error message.
It seems to take issue with the opening template literal tag. The file in question employs a simple module export function. I've stripped down the code a bit to make it easier to read. See below:
exports.templateModule = function(markup, edmData) {
var template = `<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body></body>
</html>
`;
return template;
I'm using node version v6.11.0.
The production server is running on linux.
package.json file below incase it helps.
{
"name": "template",
"version": "0.0.0",
"description": "A simple tempate test.",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"ejs": "^2.5.6",
"ejs-lint": "^0.3.0",
"express": "4.15.2",
"glob": "^7.1.2",
"node-dev": "^3.1.3"
},
"repository": {
"type": "git",
"url": "https://github.com/heroku/node-js-getting-started"
},
"license": "MIT",
"devDependencies": {
"node-dev": "^3.1.3"
}
}
I'll provide any other information you need if I can.
Any help or insight would be much appreciated.
Thank you
Moe
Template strings were added in NodeJS v4.0.0.
Node.js v4.0.0 contains V8 v4.5, the same version of V8 shipping with the Chrome web browser today.
This brings with it many bonuses for Node.js users, most notably a raft of new ES6 features that are enabled by default including block scoping, classes, typed arrays (Node's Buffer is now backed by Uint8Array), generators, Promises, Symbols, template strings, collections (Map, Set, etc.) and, new to V8 v4.5, arrow functions.
If you are using an older version of Node.js on your production server, please consider upgrading it to a more recent version.
I have a socket server that I want to deploy in my Jelastic NodeJS setup. It is made of 2 files, being server.js the main file, the one started/opened by node, and worker.js the file opened as a child process by the server when required (each child handles a socket).
I never deployed a project via Jelastic or any other cloud PaaS/hosting. How should I proceed to do this?
I know that I have to write the package.json, but that's all I know.
So far, this is what I've got:
//package.json
{
"name": "Myserver",
"version": "1.0.0",
"description": "My Server",
"main": "server.js",
"dependencies": {
"microtime": ">=1.2.0",
"microseconds": ">=0.0.2",
"mysql": ">=2.5.4",
"point-in-polygon": ">=0.0.0"
},
"devDependencies": {},
"scripts": {
"start": "node server.js"
},
"author": "Magister"
}
I searched on their docs but all they have is how to deploy a WEB application, but my server is not web-related, so that information is not relevant.
Any suggestions?
Do you have a public IP? Most likely WebSocket app won't work behind the proxy so far
NightmareJS on c9.io is literally a nightmare.
i cannot get it to work at all i am going to run through the whole process from start to finish.
Step 1
I create a new workspace
Hosted
Node.js
Step 2
Start Editing my new workspace
I open Package.json and add what i need heres my file.
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server",
"main": "server.js",
"repository": "",
"author": "Mostafa Eweda <mostafa#c9.io>",
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"socket.io": "~0.9.14",
"phantomjs": "*",
"casperjs": "*",
"nightmarejs": "*",
"utils": "*",
"crypto": "*"
}
}
i then run 'npm install' in the console.
Step 3
this is where it does not work i try all theses diffrent commands to get the examples running and the errors i get.
#stackoverflow:~/828481 $ cd node_modules/nightmarejs/examples/
#stackoverflow:~/828481/node_modules/nightmarejs/examples $ node server.js casper.js
Error: Cannot find module 'crypto'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:7
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:117
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:118
Error: Cannot find module 'casper'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareClient.js:4
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareClient.js:83
TypeError: 'undefined' is not a function (evaluating 'require(phantom.args[3].slice(13)+'nightmareClient.js').Nightmare({
exitOnError: false
})')
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareTest.js:16
I have it working. I also had trouble at first. I tried downloading the prebuilt package, but I can't seem to get that working. I ended up just adding the following to my package.json file and ran npm update and all was well:
"nightmare": "^1.5.0",
"phantomjs": "~1.9.7"
Probably they've updated the npm repo and everything since you've posted this. I bet it was frustrating. I don't have those examples in my install, but I would guess you could run them if you had all of the right pre-req's installed.
I've begun using Node.js to make web applications. It's really awesome. I've come across a few modules that I want to incorporate into my build. I can work with the modules in Terminal after a global npm install. When it comes time to add them to my application, I have no idea how to go about placing them in my directory structure and I haven't found any good documentation on this. My typical node.js directory is:
ROOT
Server
server.js
node-modules
Client
index.html
css
-main.css
javascript
-main.js
-jquery.js
My process for installing the modules has been:
I cd into my Server file and run npm install
Then I go to my package.json file and include the module in the dependencies
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.1.0",
"jade": "*",
"stylus": "*",
"<node-module-here>": "1.0.x",
},
"engines": {
"node": "0.10.0",
"npm": "1.2.14"
},
}
After that, I head over to the server.js file I add:
module.exports = require('<path_to_node-module_lib>');
When I run functions that are dependent on the modules on the Client side (functions that work in Terminal), I don't receive an error but the function won't run. Because I'm not receiving errors I have no idea about how to debug. If anyone can recognize some fatal flaw in my structure or implementation and can offer some recommendations, I offer my first born.