Parcel showing ENOENT: no such file or directory error when I save my html - package.json

beginner web dev here, first time using parcel and sass.
So, I have the parcel set up, but when I change and save the src/index.html, terminal shows me this error, instead of changing the dist/index.html.
It is very weird because in the error, there is supposed to be a file called dist/index.html.9424.5, which really does not exist in my case.
Here is my package.json set up:
{
"name": "calculator_project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "parcel src/index.html",
"build": "parcel build src/index.html"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#parcel/transformer-sass": "^2.7.0",
"parcel": "^2.7.0",
"sass": "^1.55.0"
}
}
Also, this is my folder structure and html
I will be very thankful for any tips or solutions.
Also, I am very sorry if I documented this error incorrectly, I am still pretty new to this.
Thanks for reading and help!

Related

IntelliJ and WebStorm treating npm linked local module as an indirect dependency, and not using it in it's suggestions

I have a local node module I am trying to reuse in my other modules.
I use npm link to add the module as a dependency to other modules.
Everything works fine, however IntelliJ Treats this as an indirect dependency even if I add the dependency to the pom. Because of this none of the autocompletions for the dependency work.
Pom1:
{
"name": "test-module",
"version": "1.0.0",
"description": "\"Module functionality testing project\"",
"main": "index.js",
"scripts": {
"test": "\"No Tests done\""
},
"author": "",
"license": "ISC"
}
pom2:
{
"name": "test-module-2",
"version": "1.0.0",
"description": "\"Module functionality testing project\"",
"main": "index.js",
"scripts": {
"dev": "node index.js",
"test": "\"No Tests done\""
},
"author": "",
"license": "ISC",
"dependencies": {
"test-module": "^1.0.0"
}
}
Anyone know why this is and how to fix it?
The issue is tracked at WEB-49242, please follow it for updates.
As a workaround, please try including node_modules\test-module folder in index by selecting Mark directory as/Cancel exclusion from its right-click menu

Find unused modules in nodeJS outside package.json

I have to document and resume code from another developer which has been fired because of a lot a disciplinary trouble inside the team.
The application uses nodeJS and mongoDB and I'm a beginner at nodeJS, but webstorm help me a lot to understand how the application works.
(I precise the former dev did not leave me so much documentation, so I'm doing reverse engeeniring and cleaning here).
My question today is:
the node_modules looks like it is really huge to me, with 243 sub-repository. I'm suspecting than some of these are not usefull to the project but the package.json is not really helping here:
{
"name": "my_rotting_project",
"version": "1.0.0",
"description": "",
"main": "main.js",
"bin": "main.js",
"scripts": {
"start": "node --no-deprecation core/server",
"server": "nodemon --no-deprecation core/server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"luna": "file:./core"
},
"pkg": {
"scripts": "plugins/**/*.js",
"assets": [
"static/**/*",
"core/static/**/*"
]
},
"nodemonConfig": {
"ext": "js,mjs,json,html,css,ejs"
}
}
I have launched npx check and npx npm_check commands but they show me no unused library which seems unlikely (but both of them have written than some of dependencies was missing in package.json)
Does someone know if theses plugins are reliable enough or should I try other methods ? (and what should I do in this case ?)
thank you !

Heroku deployment fails with "missing script: start"

I am trying to upload my local MEAN stack based web application to my Heroku server. I have updated my code in Bitbucket and have successfully done the Heroku deployment part. But, the web app is still not live. When I hit the page, I am getting something like this:
I then checked the logs by firing 'heroku logs' but I am unable to understand what the logs are trying to ask for. I am sharing the logs below:
As I understand it, the application was unable to find "start" but I have later exclusively added "start" : "node app.js" but I still don't see any difference in the heroku logs or in the heroku link.
Can anyone help with what am I doing wrong here?
here's my package.json file
{
"start": "node app.js",
"name": "PerosnalPro",
"version": "1.0.0",
"description": "Personal website using dynamic routing and responsive design.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mikey",
"license": "ISC",
"dependencies": {
"dotenv": "^1.2.0",
"ejs": "^2.3.4",
"express": "^4.13.3",
"morgan": "^1.6.1",
"serve-favicon": "^2.3.0",
"slick-carousel": "^1.5.9"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://user#bitbucket.org/username/projectname"
},
"homepage": "https://bitbucket.org/username/projectname"
}
"scripts": {
"start" : "node app.js",
"test": "echo \"Error: no test specified \" && exit 1"
}
Add your start tag in scripts. :)

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

Is it possible to reference a property in package.json

Consider the following package.json:
{
"name": "expressapp",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"dev": "./node_modules/.bin/nodemon app.js"
},
"author": "me",
"license": "ISC",
"dependencies": {
"express": "^4.13.4",
"mongodb": "^2.1.7"
},
"devDependencies": {
"nodemon": "^1.9.1"
}
}
Now I want to rename my app.js to index.js. So I have to edit that name at least in two different places: main property and dev property of scripts. Is it possible to reference the value of main property inside package.json?
You can do it through environment variables
Under Linux
"scripts": {
"dev": "./node_modules/.bin/nodemon $npm_package_main"
},
Under Windows
"scripts": {
"dev": "./node_modules/.bin/nodemon %npm_package_main%"
},
JSON itself doesn't support variables.
It's up to the program consuming JSON that can decide whether to treat any particular pattern as a variable or to be replaced with some other text somehow.
While other answers have mentioned using the $ or %% notation for variables (that are OS-dependent), I think you can also solve your problem in the following way:
Instead of nodemon app.js you can just write nodemon .:
"main": "app.js",
"scripts": {
"dev": "nodemon ."
}
. will also automatically resolve to app.js
If you have a "main": "app.js" in package.json (in any folder, be it top level or sub folders) then any node process will identify the app.js file as the default one to load (either in require calls or executing via cli), just like it does index.js automatically.
Yes, you can reference to any field value from package.json when executing scripts.
But there is a difference, when you run script under windows, you should use %npm_package_field% and with unix based OS you should use $npm_package_field.
Where field is field name from package.json.
Under windows, you can use:
"dev": "./node_modules/.bin/nodemon %npm_package_main%"
Under unix:
"dev": "./node_modules/.bin/nodemon $npm_package_main"

Resources