I installed the gulp to global and local project:
npm install -g gulp
and
npm install --save-dev gulp
then I use gulp command:
gulp -v
then,display error:
module.js:471
throw err;
^
Error: Cannot find module 'through2'
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 Object.<anonymous> (/home/users/zhangzhida/output/lib/node_modules/gulp/node_modules/gulp-util/lib/noop.js:1:77)
at Module._compile (module.js:570:32)
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)
Then ,I install the through2 to global and local project. still display error like
the above. when I re-install the gulp after installed the through2 ,is also like the above.
I think it is some problem in npm ,but I don't know how to resolve it .Please help me.
While I'm not sure if it will help, here's how to use gulp.
Update NodeJS and npm
If not done already, install the latest stable version of NodeJS and immediately run:
npm install -g npm
This will update npm with npm.
Installing gulp
The first thing you see on their website is the npm commands to install the gulp package to your local project, and the gulp CLI program globally as a tool.
npm install gulp-cli -g
npm install gulp -D
Since so much people confuses the gulp package with the gulp CLI package, the doc says:
If you've previously installed gulp globally, run npm rm --global gulp
before [installing the CLI again]
Using gulp with a project
Gulp is a development dependency in your project, like any other package needed to build your project. So you shouldn't install through2 globally, only locally in the project as a dev dependency.
Related
I am new to Vue. and searched everywhere for the correct answer. But no luck. Please Help me on this.
I can't create a new vue project.
at the first I ran npm install -g #vue/cli
and after that vue create vue-animated-ui
But it gives an error,
C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\node_modules\execa\index.js:347
throw err;
^
Error: Command failed: npm --version
'npm' is not recognized as an internal or external command,
operable program or batch file.
at makeError (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\node_modules\execa\index.js:174:9)
at Function.module.exports.sync (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\node_modules\execa\index.js:338:15)
at new PackageManager (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\lib\util\ProjectPackageManager.js:126:42)
at Object.<anonymous> (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\lib\util\getVersions.js:6:12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
npm version 6.14.6 and vue cli version #vue/cli 4.5.13
Thank you in advance.
Ah! base the file path looks like you are using NVM control the node version.
So I think this issue is not vue/cli issue. it's an nvm issue.
And base on the error message it's npm v can not execute.
I suggest you first check in this path
C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\
Do you have the npm folder like this:
If not it means when you use nvm use 10.22.0 it does not install the npm.
So you can install manually
this is the node npm version: nodejs.org
node v10.22.0 should use npm v6.14.6
go to npm download the 6.14.6 version.
unzip it to your path C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\ and rename it to npm
then try npm -v if you got version. means it's work. it'll also work for vue/cli
my config
linux ubuntu 16.04 64bits
node -v v6.10.3
npm -v 5.5.1
npm ls node-sass
/home/myname/Code/myproject
└─┬ laravel-elixir#6.0.0-16
----└─┬ gulp-sass#2.3.2
--------└── node-sass#3.13.1
the error ---------------------------
Starting 'sass'...
[14:53:46] 'sass' errored after 91 ms
[14:53:46] Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (57)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.13.1
at module.exports (/home/myname/Code/myproject/node_modules/node-sass/lib/binding.js:13:13)
at Object. (/home/myname/Code/myproject/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
ps: I do (npm rebuild node-sass) and the same problem
possibly duplicate of node-sass environment error.
The fix for me was following.
There are 2 things to manage.
If you want to keep the node-sass version as specified in package.json then you will have to play with node and npm version. for me i had to keep specified version let say 3.10.1 so i used node 6.12.3 and npm v3.10.10 and then go to root folder of project and do npm install.
If you are using proper version of node and npm then remove node_modules and again do npm install. this might work
or one more thing you can do is npm uninstall --save node-sass and then
again do npm install --save node-sass
Updating my Angular 2 CLI project from 1.0.0-beta.11-webpack.2 to 1.0.0-beta.11-webpack.8 according to instructions:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#webpack
resulted in this:
jan#linux-zd16:~/src/fm-repos/fm-ui> ng --version
Cannot find module './models/config'
Error: Cannot find module './models/config'
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> (/home/jan/src/fm-repos/fm-ui/node_modules/angular-cli/addon/ng2/index.js:4:16)
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)
When installing Angular CLI, explicitly use the latest version, instead:
Update global Angular CLI
rm -rf node_modules dist tmp
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#latest
Update project's Angular CLI
npm install --save-dev angular-cli#latest
Update project's configuration files
ng init
and carefully review each difference.
Angular 2 has very recently changed it's build engine from SystemJS to Webpack in it's latest release. Which could be one (amongst other) reasons for this error message (it was for me anyway).
If you want to ensure you use the latest, like discussed on their git page, you can run:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#latest //in theory, npm install -g angular-cli should be OK
Now your project is likely still 'setup' to use the previous build system, so it's easier to delete your node_modules, and reinstall:
rm -rf node_modules
npm install
You can verify the installation via:
ng build
Tell me what extra information you need
Im following a simple guide to activate my first angular 2 app and did the following actions on the clr:
npm i -g angular-cli //(worked)
ng new ponyracer //(error: Cannot find module 'glob')
ng serve //(error: Cannot find module 'glob')
Cannot find module 'glob'
Error: Cannot find module 'glob'
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:\Users\stavalfi\AppData\Roaming\npm\node_modules\angular-cli\addon\ng2\tasks\lib-install.js:11:19)
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)
Any explations about the commands "ng new ponyracer" and "ng serve" will be great.
Thanks,
Stav
There's already an issue reporting this error message. The workaround until the next release is to install glob for the project (npm install --save glob)
Regarding the commands, according to their repository under Generating and serving an Angular2 project via a development server the commands are as follow
ng new ponyracer : This command will create a project named ponyracer (a folder named ponyracer with all the set up in it).
ng serve : This command will run the live reload server to serve the application so you can see it in your browser.
PS : If you test the solution suggested in the issue it would be nice of you to report if it worked or not.
PS2 : I tested now (I fixed my error) and I cannot reproduce your error. I'm using node v5.5.0 and npm v3.7.3. Can you specify which node and npm versions are you using?
I had the same error on Windows 10,
D:\Code\AngularJS>ng new greetings-ac
Cannot find module 'glob'
Error: Cannot find module 'glob'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\Code\node_modules\angular-cli\addon\ng2\tasks\lib-install.js:11:19)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
but the following fixed it:
D:\Code\AngularJS>npm install -g angcli
D:\Code\AngularJS>ng new greetings-ac
? Select project blueprint: Default template
Cloning into 'D:\Code\AngularJS\greetings-ac'...
install installing using npm
npm WARN package.json angularApp#0.0.0 No description
npm WARN package.json angularApp#0.0.0 No repository field.
npm WARN package.json angularApp#0.0.0 No README data
npm WARN deprecated lodash-node#2.4.1: This package has been discontinued in favor of lodash#^4.0.0.
npm WARN optional dep failed, continuing fsevents#1.0.7
npm WARN deprecated lodash-node#3.10.2: This package has been discontinued in favor of lodash#^4.0.0.
npm WARN optional dep failed, continuing fsevents#1.0.7
For now, run npm install --save glob in your project, or install globally npm install -g glob like Eric mentioned.
This is listed in Issue #233 on the angluar-cli project.
The missing glob dep has been fixed in latest master. This will go out
in the next release. - posted 4/21/16
Versions ran with this fix:
angular-cli: 0.0.33
node: 5.9.1
glob: 7.0.3
angular2: 2.0.0-beta.14
I had the same issue.
Cannot find module 'module_name'
Error: Cannot find module 'module_name'
When I run the command:
npm install --save module_name
Note: Here the 'module_name' is the name of the missing module. example: fs-extra, glob, dependency-graph, sort-package-json, #phosphor/coreutils, prettier etc.
It throws a new error that a new module is missing. And it kept happening everytime I try to fix an error, a new error pops up the next time(other packages mentioned above).
Here's what I did to solve the error:
I had to uninstall and unlink nodejs and npm :
Note: use unlink only if you have linked them before, otherwise, it's not necessary
brew uninstall node
brew unlink node
brew unlink npm
brew unlink node_modules
Make sure you remove all the node_modules, npm and nodejs folders from your system.
My commands below can be different from yours. You can manually search for folders and remove them as well:
rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp
After uninstalling and deleting all node, npm folders, I ran these commands:
brew install node
npm install yarn -g
npm install -g typescript
npm install
yarn install
That fixed all the issues
remove node_modules
remove package-lock.json
npm i
npm run ...
I tried this tutorial to basically setup my gulp project and activate less processing and watching. It works. Now I'd like to install the modules globally, in order to acces them from everywhery on the machine and not to installa them for every project:
npm install --global gulp-less
npm install --global gulp-watch
npm install --global gulp-autoprefixer
npm install --global gulp-plumber
Now I want to run gulp in my project folder, but gulp cannot find the globally installed modules:
$ cd /my/project
$ gulp
module.js:327
throw err;
^
Error: Cannot find module 'gulp-less'
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> (/root/temp/gulptest/gulpfile.js:9:12)
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)
How to get it working and use global gulp modules?
The solution was npm-link. I had to link all my local packages to global counterparts:
npm link gulp
npm link gulp-less
npm link gulp-watch
npm link gulp-autoprefixer
npm link gulp-plumber
npm link path
Now it works.
Some StackOverflow posts to this subject:
"Skip local installation of Gulp"
Aperçu's answer
"Why do we need to install gulp globally and locally?"
Derek Greer's answer
1. Install gulp globally:
If you have previously installed a version of gulp globally, please run npm rm --global gulp
to make sure your old version doesn't collide with gulp-cli.
$ npm install --global gulp-cli
2. Install gulp in your project devDependencies:
$ npm install --save-dev gulp
Read more... https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md
For what it's worth, I solved this by placing this line at the top of my gulpfile.js
module.paths = module.paths.concat(module.parent.paths);
My parent module knew my npm global directory, but while running gulpfile.js, a child module seems to be created which doesn't. Instead, module paths is only relevant to the current directory from where the project is being run from and then each previous directory back to the root of my drive.