npm ERR! extraneous: pug#2.0.0-alpha6 - javascript

I need some help. I am just learning to build a website with node.js.
I have installed node v4.5.0, npm 2.15.9, coffeescript 1.10.0
I am following instructions from a book "CoffeeScript and Node.js".
I have this file package.json:
{
"name": "todo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.0.0beta6",
"jade": "*",
"socket.io": "*",
"coffee-script": "*",
"connect-assets": "*"
}
}
I ran the command: npm install, after which some warnings were shown, about jade being deprecated, and that pug had to be installed.
I have changed jade to pug in the package.json file, and ran npm install again. And again there were some warnings, about newer versions of pug! Made some changes again, at last this ERR appeared!
I would appreciate some help, how to go on.
Note: the example code is from quite an old book (2012), and never updated
How should I proceed? I have a directory tree with both jade and pug. Will that work? Or should I update node and/or npm?
EDIT: I got most of it working now, but another issue came up. Should it be related to the previous ones?
The issue: I installed another helper module: npm install supervisor -g. When I run supervisor app.coffee, at first everything looks right, but after making changes in one of the files, the console display goes wild. I have to stop it, and this is what came out:
Starting child process with 'coffee.cmd app.coffee'
Listening on port 3000
events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:907:11)
at exports._exceptionWithHostPort (util.js:930:20)
at Server._listen2 (net.js:1250:14)
at listen (net.js:1286:10)
at Server.listen (net.js:1382:5)
at Function.app.listen (C:\Examples\todo_node\todo\node_modules\express\lib\application.js:533:24)
at Object.<anonymous> (C:\Examples\todo_node\todo\app.coffee:13:5)
at Object.<anonymous> (C:\Examples\todo_node\todo\app.coffee:1:1)
at Module._compile (module.js:409:26)
at Object.exports.run (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\coffee-script.js:134:23)
at compileScript (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:224:29)
at compilePath (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:174:14)
at Object.exports.run (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:98:20)
at Object.<anonymous> (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee:7:41)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3
Program coffee.cmd app.coffee exited with code 1
Starting child process with 'coffee.cmd app.coffee'
Received SIGINT, killing child process...
Parent process exiting, terminating child...
Second EDIT; I have read that Error: listen EADDRINUSE :::3000 is indicating that the 3000 address is in use. I have no idea what might be using it, but rather I'd like to know how this can be avoided. I am running this app on Windows 10, that just had an update today.
And, moreover, I have no problems running the app with the command coffee app.coffee. Drawback is that this has to be closed and started again each time a file is changed.
I hope someone can help me further,
Thank you,
Ad

Jade is the old name of the Pug templating engine.
Use Pug, latest version is 2.0.0-b6 :
Pug page on NPM
You can try it on the page, in your browser.
If NPM fails, try GitHub repository
If you aren't comfortable with versions, just use :
npm install pug --save
To automatically add Pug into your package.json (with the correct, latest version).
Edit : which warnings/errors do you have ? Can you post it please ?
Edit 2 : your Express version is outdated too.

Related

NPM Run Watch is Not Working For React Project

Hello Im trying to use NPM Run Watch so I can see localhost:3000 for my React Project but I'm getting a weird error so I don't even know where to begin.
Rubens-iMac:react-redux rubenesquivel$ npm run watch
> CodingPhase-StarterKit#1.0.0 watch /Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux
> gulp
fs.js:45
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:45:5
at req_ (/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux/node_modules/natives/index.js:143:24)
at Object.req [as require] (/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! CodingPhase-StarterKit#1.0.0 watch: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the CodingPhase-StarterKit#1.0.0 watch 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! /Users/rubenesquivel/.npm/_logs/2021-02-20T22_29_40_150Z-debug.log
Rubens-iMac:react-redux rubenesquivel$
Not sure if anyone is familiar with this guy but I'm using codingphase starter package and before I did npm run watch I installed gulp I had some errors but I fixed using commands from stack over flow so Im worried maybe I did something to cause this on accident. I hope this makes sense.
I think I saw this error before:
First, make sure you are in the root directory of the project
Second, make sure you did run npm install
Third and most importantly, check if this project is inside another project. Meaning that you should go up level by level and check if you have a package.json file and some node_modules installed in any one of these directories:
/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/
Please, let me know if this does not solve your problem
Ok I figured out what was causing the issue. The main folder I put the react project in had spaces in it. For Example I had it called Calendar web app and should have called it calendar-web-app. Yeah i know this was a rookie mistake but figure ill let everyone know in case it happens to anyone else. Thanks to everyone who took the time to help out.

Ember.js - Error when running ember --version command

I am trying to run an ember.js app on my laptop but after installing the ember-cli and trying to run ember --version command I get an error.
To install ember-cli I used the following command - npm install -g ember-cli
It is probably important to mention that when I run ember --version command outside of the app directory it works, but when I run it inside app directory it crashes and gives error.
Node.js version - 8.11.3
This is the error that I get:
ember --version
/Users/user/go/src/github.com/apps/app/node_modules/ember-cli/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/user/go/src/github.com/apps/app/node_modules/ember-cli/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
As suggested in comments by Buck Doyle I changed Node.js version to 14.5.0 and ran ember --version command again, but I got a different error this time:
Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (83)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.13.1
Stack Trace and Error Report: /var/folders/bt/p_dtgwnd23gbv8nc7v_wpzmr0000gn/T/error.dump.ddc14c42b05e40a5181262bd0b9ad027.log
It is probably important to mention that when I run ember --version command outside of the app directory it works, but when I run it inside app directory it crashes and gives error.
Just wanted to answer this small piece. When you run ember inside of a directory with a package.json that includes ember-cli it will run the version of ember installed there. This is really nice when you're moving between a few apps with different versions of ember-cli, but can be surprising in situations like this.
replace catch with catch (error)
just had the same problem and solved it by replacing catch with catch(error) so you need to add (error) next to each catch.
i needed to change this in about 10 files. so you gotta change every time and run it so you see the new location of the error. best of luck

npm ReferenceError: primordials is not defined (node.js)

I know this question is posted many times but I tried the solutions and I can not resolve it. I am trying to work wit npm however I get this error:
evalmachine.<anonymous>:35
} = primordials;
^
ReferenceError: primordials is not defined
at evalmachine.<anonymous>:35:5
at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:8)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:3:27)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
I can not even execute npm -v to see the version.
I tried to downgrade node to version 10.
I tried to uninstall-reinstall node so many times (From remove application settings).
I tried to create a file called "npm-shrinkwrap.json" insde the npm folder where package.json exists.
But there is no use.
And I can't see an "AppData" folder in the "Users/User" path but I can access it by "cd" from the command line. I don't understand how it is not visible.
Thank you.
It is resolved!
I know I said I uninstalled npm, but just uninstalling it from the settings were not enough. I tried to uninstall it deleting the node releted directories on my computer following this post: https://stackoverflow.com/a/11178106/13806114. And then I installed node again and it worked!
Thank you.
It's looking for the "primordials" method in graceful-fs, trying to reinstall this dependency.
About npm, try reinstalling nodejs again, probably your npm is corrupted
About AppData is not visible or is a hidden directory in Windows, you can access it by path in Windows Explorer

Why do I keep getting "Cannot find module 'socket.io'"?

I have been trying to use socket.io in my NodeJS script, but I'm constantly getting the error "Cannot find module 'socket.io'".
Full error:
$ sudo node /var/www/apache/server/serverScript.js
module.js:549
throw err;
^
Error: Cannot find module 'socket.io'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/www/apache/server/serverScript.js:59:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
I've tried installing socket.io globally, I've updated everything npm related, and tried all other common suggestions I found online, but the error hasn't changed.
If I had to guess, I think it's related to the package.json file. I started off with NodeJS just recently, and never used a package.json file. I saw somebody mention it as a fix, so I added one through npm init. This placed it in /home/pi. Since this didn't help, I moved the file to the js file location: /var/www/apache/server. Unfortunately, no luck.
Can anyone tell me what's causing this issue?
It's hard to give a good answer without any of your source code. However, you can try do to this.
Open your cmd or terminal.
cd into your project folder.
Run the command: npm i --save socket.io
Within your source code, type const io = require('socket.io'); to import socket.io.
Have you place this code at the bottom of your render document (like index.html for example) ?
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
You can just install socket IO inside your project not globally.
If you are developing in NodeJS, you need to add the package library to your package.json. This can be done by doing:
npm install --save socket.io
Note: If your npm install fails to install socket.io, try to:
Install node-gyp globally: npm install -g node-gyp
Create a .npmrc file with this in the content: #types:registry=https://registry.npmjs.org/
which is going to add this line to your package.json:
"dependencies": {
"debug": "~3.1.0",
...
"socket.io-adapter": "~1.1.0",
"socket.io-client": "2.1.1",
"socket.io-parser": "~3.2.0"
},
Note: the dots are other packages library that may exists in there.
Then, you can use it in your code:
const io = require('socket.io');

NPM Permission errors even after resetting ownership

Been trying to install nodemon globally and although installed, I got a permission error when trying to run nodemon app.js in my terminal (using zsh). The following error:
/usr/local/lib/node_modules/nodemon/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/Users/carlosgrijalva/.config/configstore/update-notifier-nodemon.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at Object.get (/usr/local/lib/node_modules/nodemon/node_modules/configstore/index.js:34:26)
at Object.Configstore (/usr/local/lib/node_modules/nodemon/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/index.js:34:17)
at module.exports (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/index.js:123:23)
at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/bin/nodemon.js:15:27)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I found this article: https://docs.npmjs.com/getting-started/fixing-npm-permissions
And followed the instructions in option 1 by running the following command:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
I'm debating reinstalling node and since i'm using 6.11 and figured I might as well use the latest version but I'm unsure if that's the wisest move at this point. If anyone has any other suggestions I'd really appreciate it.

Categories