When I compile with gulp i got an error like below.
Operating system Windows 10
gulp serve
module.js:471
throw err;
^
Error: Cannot find module './gulp/uild.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at D:\test\gulpfile.js:13:3
at Array.map (native)
at Object.<anonymous> (D:\test\gulpfile.js:12:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
Could we see your gulpfile.js file?
Inside, it must have something like this:
var gulp = require('gulp');
gulp.task('default', function() {
// place code for your default task here
});
Another option is to run npm install.
Taken from the docs:
npm install (in package directory, no arguments):
Install the dependencies in the local node_modules folder.
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
By default, npm install will install all modules listed as dependencies in package.json.
With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.
Looks like you are missing b letter in build in ./gulp/uild.js in D:\test\gulpfile.js at line 13
Related
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
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
Hello I am new in a nodejs and when I run any file in command prompt like:-
C:\demoData>node demo.js
I get error li9ke this
module.js:327
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\demoData\shahzad.js:1:77)
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)
I did R&D and get the solution
npm install express
And my Problem has solved using this. But Why I required this I have already express folder globally.this path
C:\Users\broswire\AppData\Roaming\npm\node_modules;
I want to use this node_modules, I don't want locally node_modules.
Node encourages using locally installed modules. Generally, using modules installed with npm install --global or npm install -g should be reserved for cli tools and things used systemwide. So to use express in a project, it is recommended to npm install express in that directory. It is also useful to add a package.json file to save the versions of your dependencies. Then you can just navigate to your project and run npm install and it will install the required dependencies.
So i moved to the directory where the .js file is located and i opend it with node filename.js got nodejs and everything installed on the ubuntu VPS and i get error:
throw err;
^
Error: Cannot find module 'is-property'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/www/bot/node_modules/steamcommunity-mobile-confirmations/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/index.js:1:80)
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 Module.require (module.js:353:17)
at require (internal/module.js:12:17)
what is the problem? or m i trying to run this file completly wrong?
It looks like you need to install a dependency.
Try running the following command in your terminal
npm install is-property --save
If you're trying to run a script with a package.json file, that should define all the dependencies you need. All that's left to do is run npm install in the project directory.
If there's no package.json defining dependencies, you'll need to install each missing dependency. As you've found out, it'll throw a missing module error if they're missing. You might run into this issue multiple times if there are multiple missing modules. To remedy that, either dive into the code, and look for require('package-name') statements that don't reference a local path. (E.g. require('./package') is a local file, whereas require('package') will look for an npm installed module.) Alternatively, you can just keep trying to run it, and install each missing dependency manually until it stops spitting out errors.
I highly recommend creating a package.json if one doesn't exist yet. You can use npm init, and any installed packages should be automatically added to it. Then you can save additional packages to it using npm install package-name --save, or npm install package-name -S. That way, if you use the same code on another machine/in another directory, you don't have to copy over the node_modules folder, as you can specify which packages/versions you want and install them with a single npm install.
Additionally, you may wish to read up on what the package.json file is in relation to node.
NPM Docs on package.json
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.