Generating a bin folder in NodeJS with Fedora - node.js

I'm learning to do CRUD in Node, and am having trouble generating the bin folder. Also, the package.json folder which I've generated doesn't contain the dependencies needed to run on localhost.
To generate the app, I used express MyApp
and then npm install npm install mongoose --save
This gave me:
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.5.2",
"jade": "*",
"mongoose": "^4.5.4"
}
}
It did not generate a bin folder, or www file hiding elsewhere. I'm using Fedora 23, in case that makes a difference here. Please let me know if there's something I've missed, or if you have any suggested work-arounds.

Related

How to update vite 3 project to vite 4?

I have a vite 3 project. How can I update it to vite 4? Do I need to make a new project from scratch and copy the files? Or do I simply update the version number in package.json, delete node_modules folder and do npm install?
https://vitejs.dev/blog/announcing-vite4.html
They didn't announce any breaking changes so I think you can just upgrade to 4 in packages.json...
I'm gonna try it too.
I find the best way to figure this out is to look at the source code of the npm create template they have.
For example, looking at the vue-ts one from https://github.com/vitejs/vite/blob/main/packages/create-vite/template-vue-ts/package.json you can see the following package file, and then just use that as a guide:
{
"name": "vite-vue-typescript-starter",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
},
"devDependencies": {
"#vitejs/plugin-vue": "^4.0.0",
"typescript": "^4.9.3",
"vite": "^4.1.0-beta.1",
"vue-tsc": "^1.0.24"
}
}

Node saying sh: 1: main.js: not found when main.js is there

As the title says, node cannot find main.js. I am doing this through replit and my .replit file is run = "npm test". My package.json file is
{
"name": "Adventure",
"version": "1.0.0",
"description": "This is The Adventure Bot By BrainDead_Dev",
"main": "main.js",
"dependencies": {
"#replit/database": "^2.0.1",
"discord-buttons": "^4.0.0-deprecated",
"discord.js": "^13.6.0",
"moment": "^2.29.1",
"winston": "^3.6.0"
},
"devDependencies": {},
"scripts": {
"test": "main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/BrainDeadDev/Adventure.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/BrainDeadDev/Adventure/issues"
},
"homepage": "https://github.com/BrainDeadDev/Adventure#readme"
}
This is for a discord bot, and it has been working perfectly fine up until the point where I wanted to update discord.js and had to reinstall npm. Any help would be appreciated as I am quite lost.
When you updated the discord.js package, it now requires a more current version of node js (v16.6).
To update to the version of node using npm simply run:
npm install -g n
If you are using nvm you can do:
nvm install 16.6
then tell nvm to use the new version:
nvm use 16.6
Then you can check the version you are using by running:
node --version
Edit for Repl.it:
following this blog, you should be able to do it by running this:
npm i --save-dev node#16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH
You can also try following this question on repl.it forums

The command moved into a separate package: #webpack-cli/serve

I looked at and executed almost every single answer on this post:
The CLI moved into a separate package: webpack-cli
It has not helped.
Allow me to present my case:
So I have developed a container folder, a separate application where I ran npm init -y and then installed the following:
npm install html-webpack-plugin#4.5.0 nodemon webpack#5.3.2 webpack-cli#4.1.0 webpack-dev-server#3.11.0
Then I went into my package.json file and added the start script:
{
"name": "container",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack serve"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"html-webpack-plugin": "^4.5.0",
"nodemon": "^2.0.6",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"
}
}
When I go to terminal and run npm start, this is why I get every single time:
➜ container npm start
> container#1.0.0 start /Users/luiscortes/Projects/ecommRS/container
> webpack serve
[webpack-cli] The command moved into a separate package: #webpack-cli/serve
? Would you like to install #webpack-cli/serve? (That will run npm install -D #webpack-cli/serve) (Y/n) › true
And yes even if I choose Y or true and it runs its npm install -D #webpack-cli/serve, when I go back to running npm start it just gives me the same error over and over again.
Apparently, this is an issue with webpack-cli#4.1.0. I upgraded to webpack-cli#4.2.0 and now it works.

Yarn link: Importing graphql-js project into another graphql-js project showing another module or realm error

I am using graphql-js instead of SDL for designing my graphql server. For this, I have created a small library which depends on graphql-js.
Thus, I am linking this library into my main project using yarn (yarn add link:../lib) to build graphql objects and schema.
My package.json files are given below
graphql-lib/package.json
{
"name": "graphql-lib",
"private": true,
"version": "0.1.0",
"description": "",
"main": "index.ts",
"dependencies": {
"graphql-iso-date": "^3.6.1"
},
"devDependencies": {
"#types/graphql-iso-date": "^3.4.0",
"#types/jest": "^25.2.3",
"#types/node": "^14.0.5",
"jest": "^26.0.1",
"ts-jest": "^26.1.0",
"typescript": "^3.9.3"
},
"peerDependencies": {
"graphql": "^15.1.0"
}
}
core/package.json
{
"name": "#core/schema",
"private": true,
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"graphql-lib": "link:../lib",
"graphql": "^15.1.0",
"graphql-iso-date": "^3.6.1"
},
"devDependencies": {
"#types/graphql-iso-date": "^3.4.0",
"#types/jest": "^26.0.0"
}
}
graphql-lib testing using ts-jest is working fine.
However, when I am testing my main project I am getting following error -
Cannot use GraphQLScalarType "Float" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
graphql module in the node_modules directory contains only the graphql-js version 15.1.0. I have remove and reinstalled the node_modules in both the packages.
My understanding is that there should single executions instance of graphql. Am I missing something such that graphql instance is created in both the project? Can I link my project using yarn and maintain a single graphql instance?
That error only occurs when there are multiple copies of graphql-js in your dependencies. Most commonly it's because there are multiple versions in your node_modules. You can verify that's the case by running npm ls graphql or yarn ls graphql -- if you see multiple versions listed in your dependencies, that's a problem. Typically, this only happens when you have dependencies that directly depend on graphql-js (instead of making it a peer dependency). If you use yarn, you can use it's selective dependency feature to get around that issue.
When you're doing local development of multiple packages, you can also run into this issue because you have two different copies of graphql-js -- one in each of your two projects. That happens because npm link or yarn add link only creates a symlink from one of your project's node_modules to the other project. As a workaround, you can link graphql-js as well. Go into node_modules/graphql inside project A and run npm link/yarn link. Then go into the root directory for project B and run npm link graphql/yarn link graphql. Now project B will use project A's copy of the library instead of its own.

How can I publish a nodJS app on aws?

I'm using a free tier version of aws cloud, and have some trouble with loading up a nodeJs Application. I 've tried to follow the documentation of aws but it didn't work unfortunately. I choose the Elastic BeanStalk, from the services, and create a new Application. I choose nodeJs for the preconfigured platform of course. I make a zip with my app, and I really pay attention, to not have any parent folder above package.json, and app.js . As you can see on the picture above, I have a folder "public" which contains additional folders (css,img, javascript code). When I try to upload the project, I get an error message.
"Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js." In the project view I've got a health status "degraded", and an other error code: "i-045ac359227e3a9ae" Severe
I 've tried many php projects on this server, and everything worked fine,but I can't make it work with Node. Could you help me out please?
package.json:
{
"name": "kutyapplikacio",
"version": "1.0.0",
"description": "Egy alkalmazás kutyáknak és gazdáiknak",
"main": "server.js",
"scripts": {
"test": "test",
"start": "node server.js"
},
"author": "sethdevelop",
"license": "ISC",
"dependencies": {
"body-parser": "^1.17.2",
"express": "^4.15.3",
"express-mailer": "^0.3.1",
"express-mysql": "0.0.1",
"express-validator": "^3.2.0",
"mysql": "^2.13.0",
"nodemailer": "^4.0.1",
"nodemailer-smtp-transport": "^2.7.4"
}
}
The error message you wrote is : "Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js."
From the folder I only see you have app.js file.
And in your package.json, there are server.js:
"main": "server.js",
"scripts": {
"test": "test",
"start": "node server.js"
}
Perhaps you should change server.js to app.js ?
Update
Since you mentioned they have the same name:
could it be you zipped the folder instead of zipped the files ?
Same problem has been discussed here:
https://forums.aws.amazon.com/message.jspa?messageID=477087
https://forums.aws.amazon.com/thread.jspa?threadID=130140

Resources