First time posting, please be gentle...
Trying to follow along with Kevin Powell tutorial on setting up gulp to automate some SCSS compiling etc - link below
https://www.youtube.com/watch?v=QgMQeLymAdU&t=633s
Fairly confident I followed the instructions correctly but when trying to run the gulp style command I'm getting the following error.
node_modules seems to be set up correctly in the root folder when installed and package.json has gulp in the dependencies as well.
Any help would be fantastic.
Error: Cannot find module 'gulp;'
Require stack:
- C:\Users\Admin\OneDrive\Desktop\test\gulpfile.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\shared\require-or-import.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\index.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\Admin\OneDrive\Desktop\test\gulpfile.js:1:14)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Admin\\OneDrive\\Desktop\\test\\gulpfile.js',
'C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\gulp\\node_modules\\gulp-cli\\lib\\shared\\require-or-import.js',
'C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\gulp\\node_modules\\gulp-cli\\lib\\versioned\\^3.7.0\\index.js',
'C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\gulp\\node_modules\\gulp-cli\\index.js',
'C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\gulp\\bin\\gulp.js'
]
}
Tried deleting node_modules and npm install againw it the same issues.
If you have any previously installed gulp globally, Uninstall them using the below command :
run npm rm --global
and then try running the below and install gulp-cli globally:
npm install --global gulp-cli
And then go to your project directory and run the below command:
npm install --save-dev gulp
Please find the official gulp documentation here
Related
We've got some error and we try to install optionator but nothing happened. We're using Linux
We're trying to npm i from package.json which include this dependencies
"optionalDependencies": {
"eslint-config-<name>": "github:<username>/<repo>"
}
then we tried to run npm i optionator but still get the same error
Error: Cannot find module 'optionator'
Require stack:
- /usr/share/nodejs/eslint/lib/options.js
- /usr/share/nodejs/eslint/lib/cli.js
- /usr/share/nodejs/eslint/bin/eslint.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/usr/share/nodejs/eslint/lib/options.js:12:20)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/nodejs/eslint/lib/options.js',
'/usr/share/nodejs/eslint/lib/cli.js',
'/usr/share/nodejs/eslint/bin/eslint.js'
Anyone who experienced this, please help us. Thanks
So if you have not done an npm init then that is the issue. npm init initializes the project and will add the node_modules folder to the working directory, this will set it up as a node project. Then to install a dependency just run a npm install <dependency> although I do recommend doing a --save afterwards as well as it just ensures that the package is put in your current directory
$ npm init
$ npm install optionator --save
npm-init | npm Docs
Nothing worked until when I initialized the project in a new directory and reinstalled all the dependent modules afresh.
Need to give full access to package-lock.json
If you are using linux do this
sudo eslint init
I have installed node.js. Node seems to be working properly, however, npm is not being found, as you can see below.
C:\Users\jpdrc>node -v
v6.5.0
C:\Users\jpdrc>node hello.js
node is installed!
C:\Users\jpdrc>npm -v
module.js:457
throw err;
^
Error: Cannot find module 'strip-ansi'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\jpdrc\AppData\Roaming\npm\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\string-width\index.js:2:17)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
I have tried multiple solutions as the ones presented:
1- Windows -installed node.js but npm not found
2- Installing Node.js (and npm) on Windows 10
I have no idea what to try next
Thanks for the assistance
Here are my variables under path
As suggested below I have used where npm
C:\Users\jpdrc>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
Steps for solving the above issue:
Check that you have added the path of node in environment variable "path"
If it is there then check that npm is there in the directory which you have added in the path.
If npm is there in the required folder then go to CMD and then go to directory where npm is installed and try to run the version command again. If still you are getting the same issue then there could be two possibilities:
a. Installation is incorrect, try installing again
b. There could be proxy issue due to which packages are not getting downloaded
There cannot be any other issue.
You should be able to run the npm -v in the git bash terminal window. If you don't even have the git-bash app, then download and install git on your Windows.
I tried to setup ghost after installing node.js but as I run the install for ghost as
npm install --productions
It gives me the following error
> ghost#0.5.10 start /home/kedarkhetia/Downloads/ghost-0.5.10
> node index
module.js:340
throw err;
^
Error: Cannot find module 'streamsearch'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/kedarkhetia/Downloads/ghost-0.5.10/node_modules/busboy/node_modules/dicer/lib/Dicer.js:5:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
any help is appreciated.
Try running
npm install streamsearch
Does this work?
This may be related:
Cannot install packages using node package manager in Ubuntu
Make sure you have installed streamsearch.
npm install streamsearch
If it is still not working, check that you have cloned stable for production or not. If you did, re-clone it and do installation steps again. Use sudo for npm/grunt commands (if you are on OSX or Linux) for npm ERR!.
I just looked at the Ghost Docs, and it says to install the dependencies for production you must run npm install --production and not npm install --productions. Once you install streamsearch, it will keep complaining until you have installed all the individual dependencies with npm install --production.
Hope this helps!
I'm using meteor and meteorite's npm module. Not sure the issue is even related to that but ... I have a small project I'm trying to deploy to a vagrant virtualbox but when I start it I get
module.js:340
throw err;
^
Error: Cannot find module 'underscore'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/projects/myapp/live/programs/server/boot.js:5:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
I saw this question but it doesn't seem to be related. Everything works fine for me in development (meaning from the source folder vs the deployed version).
mrt --version reports
$ mrt --version
Meteorite version 0.7.4
Release 0.8.3
my packages.json for mrt npm is
{
"winston": "0.7.3",
"winston-loggly": "1.0.1"
}
Not too big. My smart.json for mrt is
{
"packages": {
"collection-api": {},
"iron-router": {},
"npm": {}
}
}
I'm not using require anywhere, only Meteor.require
I even tried
mkdir delme
cd delme
mrt create test.app
meteor bundle --directory ../live
It creates the same programs/server/boot.js including underscore which doesn't exist. I followed the instructions in the readme. I have fiber and bcrypt installed in the virtualbox like it mentions in the readme.
I tried installing underscore manually. I then started getting an error about the source-map-support module. So I added that. I then started getting an error about missing the semver module, so I added that and yet another module was missing. Clearly I've missed a step or something but I'm not having any luck finding it.
ideas?
Update #1
so I installed meteor from scratch on the virtualbox
curl https://install.meteor.com | /bin/sh
meteor create test.app
meteor bundle --directory ../test
cd ../test
rm -r programs/server/node_modules/fibers
rm -r programs/server/node_modules/bcrypt
npm install fibers#1.0.1
npm install bcrypt#0.7.7
export MONGO_URL='mongodb://user:password#host:port/databasename'
export ROOT_URL='http://example.com'
node main.js
That worked.
Checking the programs/server/node_modules directory in that one
ls test/programs/server/node_modules/
eachline fstream http-proxy keypress npm semver source-map-support underscore
esprima heapdump kexec node-aes-gcm request source-map tar
Where as the one showing the issues is
ls /var/projects/myapp/live/programs/server/node_modules
bcrypt fibers
maybe something has broken my original meteor bundle?
Update #2
SO EMBARRASSING! The issue is I have node_modules in my .gitignore and I'm transferring the files through git. :P
I have node.js install on linux, and file.js. In the same directory I have node_modules directory with lru-cache module.
file.js does the following:
var lrucache = require('lru-cache')
But when I run it, it raises the following error:
Error: Cannot find module 'lru-cache'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/opt/file.js:58:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
What is the problem? the same is working in other linux system.
Please try:
rm -rf node_modules && npm cache clean && npm install
Sometimes npm has an issue and the dependency lru-cache may not get properly installed.
Most node modules will have their own set of package dependencies so you cannot just copy the folder or clone the repository without making sure you are satisfying the module's dependencies.
The easiest way would be using npm for ALL package installations.
After you have run npm init in your project's root directory to set up your package.json use
$ npm install modulename --save
to install a package AND its dependencies. You can now safely use
var module = require('modulename');
throughout your whole project.
In case you cannot install your package via npm make sure all of its dependencies are installed as well by navigating to node_modules/modulename and running npm install (no arguments) here. This will install all dependencies that are listed in the modules own package.json file.