I'm trying to install MySQL support for NodeJS (v0.6.9) on Ubuntu. I'm issuing the following commands:
sudo apt-get install libmysqlclient-dev
I get no errors. I then install the module for Node:
sudo npm install -g db-mysql
Again. No errors. However, I do get what looks like a warning:
Checking for node path : not found
But the installation ends with:
'build' finished successfully (1.504s)
db-mysql#0.7.6 /usr/local/lib/node_modules/db-mysql
In my program source I now add:
var mysql = require("db-mysql");
But when I run this, I get the following error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'db-mysql'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/home/me/projects/node/test.js:4:13)
at Module._compile (module.js:444:26)
at Object..js (module.js:462:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:482:10)
It obviously can't find the db-mysql module.
Node.js does not looking for modules in global modules folder (/usr/local/lib) by default.
You need to install your module locally by npm install db-mysql.
You can read more about module resolving strategy here: http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders
Related
I am getting the below mentioned error and I am not able to figure out how to handle it. Versions of gulp, node and npm are mentioned below. I don't know if it is node's version mismatch with that of gulp or something else but so far any help would be much appreciated.
gulp -v
CLI Version: 2.3.0
Local Version: 3.9.1
node -v
v6.10.3
npm -v
3.10.10
ERROR
C:\xampp\htdocs\ecommerce\node_modules\engine.io\build\server.js:173
async handshake(transportName, req, closeConnection) {
^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\xampp\htdocs\ecommerce\node_modules\engine.io\build\engine.io.js:5:18)
Support for async functions was added in Node 7.6.0.
You are using Node 6.10.3.
You need to upgrade.
The oldest version of Node which is still supported (although only for a matter of weeks!) is version 12.
Upgrade to at least version 16.14.2 (the current long term support release).
install version 8.11.1 and run :
npm install
npm install gulp bower --global
npm install node-sass#latest
npm uninstall laravel-elixir
npm uninstall session
npm install --save laravel-elixir
npm install --save session
gulp
after that it will work
I am trying to upgrade to Polymer 3 from Polymer 2. My environment follows:
Debian Stretch
npm version 6.1.0
command run with root account: npm install -g polymer-cli
Any idea? Thank you in advance!
/usr/bin/polymer -> /usr/lib/node_modules/polymer-cli/bin/polymer.js
> wd#1.6.2 install /usr/lib/node_modules/polymer-cli/node_modules/wd
> node scripts/build-browser-scripts
/usr/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:90
throw err0;
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/polymer-cli/node_modules/wd/build'
at Object.fs.mkdirSync (fs.js:902:18)
at sync (/usr/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:71:13)
at Object.<anonymous> (/usr/lib/node_modules/polymer-cli/node_modules/wd/scripts/build-browser-scripts.js:6:1)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.3 (node_modules/polymer-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
This seems to be caused by npm issue #17346.
The current workaround is to call npm install -g polymer-cli with the --unsafe-perm flag until a new fix is released.
I am trying to deploy my functions on the cloud functions emulator but my terminal throws me this error:
$ functions deploy sendNotifications --trigger-http
{ Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#google-cloud/functions-emulator/logs'
at Error (native)
at Object.fs.mkdirSync (fs.js:922:18)
at Object.assertLogsPath (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/emulator/logs.js:31:10)
at new Controller (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/cli/controller.js:84:32)
at Object.exports.handler (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/cli/commands/deploy.js:124:22)
at Object.self.runCommand (/usr/local/lib/node_modules/#google-cloud/functions-emulator/node_modules/yargs/lib/command.js:231:22)
at Object.Yargs.self._parseArgs (/usr/local/lib/node_modules/#google-cloud/functions-emulator/node_modules/yargs/yargs.js:989:30)
at Object.Yargs.self.parse (/usr/local/lib/node_modules/#google-cloud/functions-emulator/node_modules/yargs/yargs.js:533:23)
at Object.main (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/cli/main.js:69:6)
at getProjectId.then (/usr/local/lib/node_modules/#google-cloud/functions-emulator/bin/functions:100:27)
errno: -13, code: 'EACCES', syscall: 'mkdir', path:
'/usr/local/lib/node_modules/#google-cloud/functions-emulator/logs' }
I have cd-ed to the functions directory and checked that I am logged in to firebase and selected the right project Id. Am i doing something wrongly?
Overview
The proper way to fix this is by changing the npm global directory to one that does not require root permission to install and run.
You really should not be requiring sudo to npm install -g.
Likewise to functions start.
Cleansing
Given that you have installed functions, presumably using sudo npm install -g #google-cloud/functions-emulator, you now need to first uninstall it equally with sudo: sudo npm uninstall -g #google-cloud/functions-emulator.
Why uninstall it? You currently have functions installed into a directory where root permissions are required to write. It does require write permission to log file as you can see from the error.
I would suggest uninstalling the other npm packages which you may have installed using sudo, except npm. You can find out what you have using sudo npm list -g --depth=0.
Changing npm global directory
I would suggest going with Option 2 described on https://docs.npmjs.com/getting-started/fixing-npm-permissions
Copy pasting solution from link above:
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:
source ~/.profile
Install global without sudo
Now that your machine has been cleansed and npm global has been configured to a directory that does not require root permissions, you should be able to install and run without sudo.
Had the same issue. For me it did not showed the permission log also..The issues is with the permissions. Try to the command with super user.
Step 1.
Start the gcloud functions
sudo functions start
Step 2.
Deploy the helloworld function which was exported.
sudo functions deploy helloworld --trigger-http
This is obviously very late for the original post. Hope this helps other who has the same error in the future.
I had the same issue turn out I hadn't installed that the requirements properly. Any one who steps in here can look at Error: EACCES: permission denied #195.
Main note of this error install all requirements properly.
I am following this laracasts video. Here is my
package.json:
{
"private": true,
"devDependencies": {
"gulp": "^3.8.8"
},
"dependencies": {
"laravel-elixir": "^2.0.0",
"bootstrap-sass": "^3.0.0"
}
}
I installed gulp using
npm install gulp
Then I executed:
npm install in the project root directory for installing the dependencies in package.json
Now when I execute gulp, I get this error:
module.js:339
throw err;
^
Error: Cannot find module 'lodash/lang/isFunction'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (D:\PhpIdeaProjects\LaravelLearning\myproject-flyer\no
de_modules\laravel-elixir\node_modules\babelify\node_modules\babel-core\lib\api\
node.js:21:29)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
Then after some research, I execute npm install theMissingModuleName (Here theMissingModuleName is lodash/lang/isFunction) which runs successfully. But again when I run gulp, I get another missind module error(For different module). I install that then it gives another.....
This cycle continues.
I have already installed gulp locally using npm install gulp -g and placed C:\Users\rahul\AppData\Roaming\npm directory in path.
So now what should I do to avoid these recursive errors?
Make sure you have updated npm to the latest version:
npm install npm#latest -g
Then check you have version 3.x.x installed:
npm -v
As of 3.0.0 npm has a flat directory structure so you shouldn't run in to max character limit issue.
After you have updated, just delete your node_modules and do:
npm install
in the root of your project.
Trying to test compoundjs with mysql but it fails.
My system is Debian 7 with following versions of nodejs & npm
$ node -v
v0.10.13
$ npm -v
1.3.4
Here is how I installed compoundjs
sudo npm install -g compound
sudo npm install -g jugglingdb --save
sudo npm install -g jugglingdb-mysql
compound init testapp --db mysql
cd testapp
npm install
$ node server.js
WARNING: JugglingDB adapter "mysql" is not installed,
so your models would not work, to fix run:
npm install jugglingdb-mysql
/srv/www/playground/node/testapp/node_modules/jugglingdb/lib/railway.js:55
if (!schema.adapter) throw new Error('Adapter is not defined');
^
Error: Adapter is not defined
at init (/srv/www/playground/node/testapp/node_modules/jugglingdb/lib/railway.js:55:36)
at CompoundServer.initialize (/srv/www/playground/node/testapp/node_modules/jugglingdb/index.js:31:19)
at CompoundServer.EventEmitter.emit (events.js:98:17)
at CompoundServer.initCompound (/srv/www/playground/node/testapp/node_modules/compound/lib/compound.js:123:14)
at CompoundServer.initCompoundServer [as init] (/srv/www/playground/node/testapp/node_modules/compound/lib/server/compound.js:53:29)
at /srv/www/playground/node/testapp/node_modules/compound/lib/compound.js:67:18
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:901:3
After getting the error above I tried
npm install jugglingdb-mysql
I still get the same error. I have tried installing jugglingdb and jugglingdb-mysql globally and locally (without -g). I keep getting the same error.
The bug is due to the jugglingdb version used in the npm deposit of jugglingdb-mysql, so the only way to fix it is to delete the directory and copy the one you use in your main project :
cd $YOUR_PROJECT_ROOT
rm -rf node_modules/jugglingdb-mysql/node_modules/jugglingdb
cp -R node_modules/jugglingdb node_modules/jugglingdb-mysql/node_modules
I haven't tries to install the adapter manually from github, maybe it works too.
The problem is reported here https://github.com/jugglingdb/mysql-adapter/issues/46