Magento 2 Grunt - package.json and grunt file - npm

I had problem with Grunt installation with Magento 2.
Below are the two issues:
After running npm install in magento 2 directory
npm install
npm WARN saveError ENOENT: no such file or directory, open '/var/www/html/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/var/www/html/package.json'
npm WARN html No description
npm WARN html No repository field.
npm WARN html No README data
npm WARN html No license field.
up to date in 0.089s
Checking grunt - grunt clean:blank
grunt clean:blank
A valid Gruntfile could not be found. Please see the getting started guide for more information on how to configure grunt: http://gruntjs.com/getting-started

After reading a few tutorials I missed these things:
Rename these three files in your magento 2 root directory
package.json.sample => package.json
grunt.js.sample => grunt.js
grunt-config.js.sample => grunt-config.js
I hope this help someone and save time.

Related

NPM install not work and make lock-json file

Hi I'm trying to install npm to run a kit.
my node version is: v12.18.3
my npm version is: 6.14.6
my folder is "test" and I'm installing npm with this command:
Kian#DESKTOP-CL16DA7 MINGW64 /d/markitdone/test
$ npm install
npm WARN saveError ENOENT: no such file or directory, open 'D:\markitdone\test\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\markitdone\test\package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
up to date in 0.845s
found 0 vulnerabilities
Could someone help me please?
Before you use npm install.
You need to create a project, either React, Vue.js or Angular in your test directory

NPM install only creating a package-lock.json?

I am working on a Microsoft Surface 3 running Windows 10. I use git bash for windows for file system management. I'm running npm version 6.14.4 and node version 12.16.2
I'm currently working on an app for some school work and want to run a lite-server instead of vscode's go live extension.
My understanding is that npm install should be run outside of the application as a best practice, but once it's running, you can go back in your terminal in vscode and use npm run start or npm run dev to get the server up. I learned that the two-step process from an online course where I cloned the instructor's work from his Github. In other words, he may have done some preliminary steps that I'm leaving out unintentionally.
I visited the npm docs and spend about an hour familiarizing myself with the technology. Found a nice, simple set of commands to get moving:
$ npm install lite-server --save-dev
(which I run in the project's root folder from git bash)
$ yarn add lite-server --dev # or yarn
...and add a "script" entry within your project's package.json file:
Inside package.json...
"scripts": {
"dev": "lite-server"
},
With the above script entry, you can then start lite-server via:
$ npm run dev
Problem is, I get loads of errors upon NPM install, no package.json file is generated (only a package-lock.json), and attempting npm run dev brings up multiple errors.
From NPM install, I see the following issues mostly:
I get deprecated warnings, chokidar, fsevents, urix, etc.
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.12: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
I am always getting this package-lock.json notice, not sure what it is:
npm notice created a lockfile as package-lock.json. You should commit this file.
Obviously loads of "skipping optional dependency" warnings:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.7 (node_modules\chokidar\node_modules\fsevents):
I get "no such file or directory" warnings:
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\smansfield\desktop\bootcamp_code_responses\class_content_1\activity_4\package.json'
I get these warnings:
npm WARN activity_4 No description
npm WARN activity_4 No repository field.
npm WARN activity_4 No README data
npm WARN activity_4 No license field.
From npm run dev I'm getting these errors:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\smansfield\Desktop\bootcamp_code_responses\class_content_1\activity_4\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\smansfield\Desktop\bootcamp_code_responses\class_content_1\activity_4\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\smansfield\AppData\Roaming\npm-cache_logs\2020-04-26T17_59_00_317Z-debug.log
I've searched all manner of blogs for any insight on these items... No one seems to have posted about these exact items:
why NPM install is responding with so many errors, deprecation, etc.
why am I only getting package-lock.json upon install?
why am I always getting these errors when I try to spin up the lite-server, especially these ENOENT codes and path errors?
Thank you for any insight you can provide me on this. I'll most certainly pay it forward.
Sam
Try run npm init first. It will initialize your project with npm.

Can't uninstall a package

I'm getting this error text when attempting to uninstall tfx-cli:
C:\Users\Admin>npm uninstall tfx-cli
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Admin\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Admin\package.json'
npm WARN Admin No description
npm WARN Admin No repository field.
npm WARN Admin No README data
npm WARN Admin No license field.
up to date in 0.14s
I'm trying to uninstall due to this issue, so I can attempt another reinstall.
The file C:\Users\Admin\package.json doesn't exist, but C:\Users\Admin\package-lock.json does. It contains a single line of text:
{
"lockfileVersion": 1
}
How to get past this?
npm by default looks for the package in local folder. You need to use -g option if you want to install/uninstall globally.
npm uninstall -g tfx-cli

How can I install Foundation for Sites correctly with npm?

I would like to create a template based on the Foundation Zurb template which can be updated easily. So my first thought was to use npm to get the package and specific versions.
The "Foundation for Sites" documentation says that Foundation can be installed with the command:
npm install foundation-sites.
If I call this command in an empty directory I get the following output:
npm WARN saveError ENOENT: no such file or directory, open '/home/robert/Documents/blog/src/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/robert/Documents/blog/src/package.json'
npm WARN src No description
npm WARN src No repository field.
npm WARN src No README data
npm WARN src No license field.
+ foundation-sites#6.4.3
Afterwards I see the following files/directories:
node_modules/
package-lock.json
From the documentation I would have expected this:
It occurs to me that I'm missing some understanding.
Is that a reasonable way to "build" the package?
npm installs dependencies into node_modules.
You want to use one of the templates eg https://github.com/zurb/foundation-zurb-template or https://github.com/zurb/foundation-sites-template which you can install using foundation-cli.

npm: ENOENT no such file or directory

I've looked at a few answers but cannot resolve this. I've completely removed Node from my system and reinstalled, but I still can't install any packages.
I get the following error every time:
npm WARN saveError ENOENT: no such file or directory, open '/Users/mattsaunders/Documents/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/mattsaunders/Documents/package.json'
npm -v shows 5.5.1
What is going on here?
It looks like you're not calling install from an npm project, so it can't find your package.json file