I am trying to view and run the examples from the puppeteer files and it wont let me run the examples... I keep getting error messages:
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
Yarn is installed and the modules folder exist.
What do i need to do to correct this issue?
The repo was pulled from the main puppeteer github: https://github.com/GoogleChrome/puppeteer
When you make git clone git#github.com:GoogleChrome/puppeteer.git and after make yarn install, you are not installing puppeteer. You are installing the packages that was used to make this repo. In this case, puppeteer.
Since the examples use the 'puppeteer' npm package, you should install it explicitly with npm install puppeteer inside the repo folder. But before do that, you have to change the package.json "name" attribute from "puppeteer" to something else, like "puppeteer-repo". This has to be done to avoid package name clashing.
So, change the package.json "name" attribute and install puppeteer node package with npm install puppeteer inside the repo folder. After that, the examples should be working.
Related
I am trying to install sass and I don't understand why I keep running into the issue shown below
I understand I should follow the instructions and run npm audit fix but when I run the command, I get an error of no package.json found, and yes, that is so because sass wasn't installed at all and thus no node-modules and the json file, how do I fix this issue?
Try running the npm init command at the root of your project to generate the package.json file and re run the command to install sass.
I am new to gulp and getting this weird error. I am using node v6.9.1, tried with node v8 and v10 as well. Gulp was working fine on my system previously but facing this after i switched to nvm. I tried after npm uninstall, removing node modules, nvm cache clean, delete nvm folder but kind of struck here. Please suggest how to resolve this issue. when i do which gulp then i get msg no gulp in (env path).
gulp -v
module.js:471
throw err;
Error: Cannot find module ‘C:\(ProjectRepo)\Users(Uid)AppDataRoamingnpmnode_modulesgulpbin'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
This is finally solved after lot solving series of issues. The above error was coming as i was working in a controlled env and npm i gulp was not installing all files and none under nvm directory. I copied them manually from another system both gulp & gulp-cli and it worked fine after that.
I am new to React js, While using npm start after install the react not working,I tried every process but no use. Thanks in advance
Error
cricdost#0.1.0 start C:\xampp\htdocs\cd-web
react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.41.2"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\xampp\htdocs\node_modules\webpack (version: 4.39.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if C:\xampp\htdocs\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cricdost#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cricdost#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XSC-10261\AppData\Roaming\npm-cache_logs\2020-02-20T04_56_31_650Z-debug.log
I had faced the same error. The solution that I found is to do the step-6 as described in Error message. That is to delete "webpack" folder of node_module folder under your root projects directory. For example
Assume that you installed "npm install create-react-app" in D:\Projects folder.
And then you ran "npx create-react-app firstproject" in D:\Projects folder. So, your actual react project folder is "D:\Projects\firstproject".
So, what I want to tell is don't delete "webpack" folder in "D:\Projects\firstproject\node_module" directory. Instead, delete "webpack" folder in "D:\Projects\node_module" directory.
And then, you can run "npm start" command in your actual react project directory "D:\Projects\firstproject".
I hope, this will work for you.
Yesterday I installed the JSDoc package using npm install -g jsdoc and used it just fine. Today when I tried to use it again, I got the following error:
module.js:96
throw e;
^
SyntaxError: Error parsing ...npm\node_modules\jsdoc\node_modules\requizzle\package.json: Unexpected token } in JSON at position 0
at Object.parse (native)
at readPackage (module.js:92:52)
at tryPackage (module.js:102:13)
at Function.Module._findPath (module.js:172:20)
at Function.Module._resolveFilename (module.js:438:25)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
I've actually gotten this numerous times before and a clean reinstall of the package fixes it, but I was wondering what keeps causing this error and if a more permanent fix were available.
When I open up the package.json file mentioned in the error, it looks like a binary file with a bunch of weird symbols.
I see that the first character is a } which kinda explains the error. Thing is all the package.json files for every package I download looks like that, and it works the first time so npm apparently can parse this.
EDIT:
Quick note: I am on my office laptop.
Ok so I cleaned out the node_modules folder and reinstalled jsdoc with npm install -g jsdoc. I checked the package.json file: it's all plaintext and looks great.
I then shut down and start up my computer. Not only is the jsdoc package.json file obfuscated, the package.json files of all its dependencies are also obfuscated! This little bug is recursive!
To test it further, I took the json file, duplicated it and renamed it PACKAGE_DUP.json and placed it right next to the original json file. I also took the node_modules folder and made a copy called NODE_MOD_DUP, again next to the original. So now there are 4 package.json files:
node_modules/package.json
node_modules/PACKAGE_DUP.json
NODE_MOD_DUP/package.json
NODE_MOD_DUP/PACKAGE_DUP.json
When I restarted my computer, the only json file affected was the package.json file in the node_modules folder (item number 1). So it's being targeted by something!
Virus scans are coming up clean, and every other json file in the modules folders and on my system as a whole are completely unscathed. Also, the package.json files that come with the modules bundled with node work fine. It's only modules installed with npm install that are giving me a problem (whether installed globally or locally for that matter).
I'v made a static single page site using grunt. I'm now trying to deploy it to heroku using the heroku-buildpack-nodejs-grunt for node grunt.
Below is a pic of my root directory:
Here's my Gruntfile package.json:
Procfile:
web: node index.html
When I run $ git push heroku master it gets to the Gruntfile and fails:
-----> Found Gruntfile, running grunt heroku:production task
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
The above errors proceed to list all local NPM modules as not found. If I list all loadNpmTasks instead of using "load-grunt-tasks", I get the exact same error.
When I $ heroku logs I get:
Starting process with command `node web.js`
Error: Cannot find module '/app/web.js'
Can anyone see where I've gone wrong?
For anyone passing by here, I wasn't able to solve the problem. This is where I got to:
In my Gruntfile, I moved npm modules from devDependencies to dependencies. Heroku was then able to install these dependencies.
However, when Heroku ran the tasks, it stops at the haml task w/ error "You need to have Ruby and Haml installed and in your PATH for this task to work". Adding ruby & haml to the Gruntfile as engines did not work.
The only thing I can think of is that maybe Heroku installs your devDependencies first, tries to run Grunt, but since it didn't install load-grunt-tasks yet, you don't get the grunt.loadNpmTasks( 'grunt-contrib-uglify' ); line (which load-grunt-tasks does for you), and thus Grunt can't find the package.
Can you try changing your Gruntfile to explicitly list out all npm modules using the grunt.loadNpmTasks() method?
EDIT:
Just remembered another thing I had to do:
heroku labs:enable user-env-compile -a myapp
heroku config:set NODE_ENV=production
(Obviously replacing myapp with your Heroku app name.)
This makes Heroku allow user set environment variables and then sets your server to production. Try that, and set your dependencies and devDependencies as you had them originally (just to see if it works).
I am coming pretty late to the game here but I have used a couple methods and thought I would share.
Option 1: Get Heroku to Build
This is not my favorite method because it can take a long time but here it is anyway.
Heroku runs npm install --production when it receives your pushed changes. This only installs the production dependencies.
You don't have to change your environment variables to install your dev dependencies. npm install has a --dev switch to allow you to do that.
npm install --dev
Heroku provides an article on how you can customize your build. Essentially, you can run the above command as a postinstall script in your package.json.
"scripts": {
"start": "node index.js",
"postinstall": "npm install --dev && grunt build"
}
I think this is cleaner than putting dev dependencies in my production section or changing the environment variables back and forth to get my dependencies to build.
Also, I don't use a Procfile. Heroku can run your application by calling npm start (at least it can now almost two years after the OP). So as long as you provide that script (as seen above) Heroku should be able to start your app.
As far as your ruby dependency, I haven't attempted to install a ruby gem in my node apps on Heroku but this SO answer suggests that you use multi buildpack.
Option 2: Deploy Your Dependencies
Some argue that having Heroku build your application is bad form. They suggest that you should push up all of your dependencies. If you are like me and hate the idea of checking in your node_modules directory then you could create a new branch where you force add the node_modules directory and then deploy that branch. In git this looks like:
git checkout -b deploy
git add -f node_modules/
git commit -m "heroku deploy"
git push heroku --force deploy:master
git checkout master
git branch -D deploy
You could obviously make this into a script so that you don't have to type that every time.
Option 3: Do It All Yourself
This is my new favorite way to deploy. Heroku has added support for slug deploys. The previous link is a good read and I highly recommend it. I do this in my automated build from Travis-CI. I have some custom scripts to tar my app and push the slug to Heroku and its fast.
I faced a similar problem with Heroku not installing all of my dependencies, while I had no issue locally. I fixed it by running
heroku config:set USE_NPM_INSTALL=true
into the path, where I deployed my project from. This instructs Heroku to install your dependencies using npm install instead of npm ci, which is the default! From Heroku dev center:
"Heroku uses the lockfiles, either the package-lock.json or yarn.lock, to install the expected dependency tree, so be sure to check those files into git to ensure the same dependency versions across environments. If you are using npm, Heroku will use npm ci to set up the build environment."