ng serve: Cannot find module 'tapable' - node.js

I just transfered my Angular 5 project from one computer to another and in the new device I get the following error when trying to ng serve:
Cannot find module 'tapable'
Error: Cannot find module 'tapable'
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> (c:\xampp\node_modules\webpack\lib\Template.js:7:17)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (c:\xampp\node_modules\webpack\lib\node\NodeMainTemplatePlugin.js:5:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
I tried to:
Remove node_modules and run again npm install.
npm install tapable
My node version is 6.11.2 with npm 5.3.
Any idea what can solve it?

Fix: I had to manually npm install webpack in order to solve this issue.

Related

How to specify that I want Node to use Windows?

I'm on a windows machine however my node is set to Darwin. Is there a command to switch ?
It's stopping me from adding a windows service and is erroring with:
Error: Cannot find module 'os-service'
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> (C:\Fusiozii\REST-API\rest.js:25:17)
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)
Node = v6.11.2
Node-gyp = v3.4.0

VSTS Angular 5 npm run failure (dep not found - dep from angular-cli)

I upgraded to angular 5 and noticed that my build keeps failing on VSTS (locally it works fine)
It looks like a dep from angular-cli cannot be found. Any solutions?
Build Output
[command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run build -- "--env=nightlybuild""
2018-01-29T19:06:23.9805943Z
2018-01-29T19:06:23.9807508Z > aes-web-portal#0.0.0 build d:\a\1\s\AESWebPortal\aes-web-portal
2018-01-29T19:06:23.9808541Z > ng build "--env=nightlybuild"
2018-01-29T19:06:23.9809016Z
2018-01-29T19:06:26.8023599Z Cannot find module 'uglifyjs-webpack-plugin'
2018-01-29T19:06:26.8041057Z Error: Cannot find module 'uglifyjs-webpack-plugin'
2018-01-29T19:06:26.8041907Z at Function.Module._resolveFilename (module.js:469:15)
2018-01-29T19:06:26.8042680Z at Function.Module._load (module.js:417:25)
2018-01-29T19:06:26.8043360Z at Module.require (module.js:497:17)
2018-01-29T19:06:26.8044136Z at require (internal/module.js:20:19)
2018-01-29T19:06:26.8046229Z at Object.<anonymous> (d:\a\1\s\AESWebPortal\aes-web-portal\node_modules\#angular\cli\models\webpack-configs\production.js:13:24)
2018-01-29T19:06:26.8047263Z at Module._compile (module.js:570:32)
2018-01-29T19:06:26.8048144Z at Object.Module._extensions..js (module.js:579:10)
2018-01-29T19:06:26.8048743Z at Module.load (module.js:487:32)
2018-01-29T19:06:26.8049274Z at tryModuleLoad (module.js:446:12)
2018-01-29T19:06:26.8049758Z at Function.Module._load (module.js:438:3)
2018-01-29T19:06:26.8050286Z at Module.require (module.js:497:17)
2018-01-29T19:06:26.8050774Z at require (internal/module.js:20:19)
2018-01-29T19:06:26.8051383Z at Object.<anonymous> (d:\a\1\s\AESWebPortal\aes-web-portal\node_modules\#angular\cli\models\webpack-configs\index.js:9:10)
2018-01-29T19:06:26.8052009Z at Module._compile (module.js:570:32)
2018-01-29T19:06:26.8052499Z at Object.Module._extensions..js (module.js:579:10)
2018-01-29T19:06:26.8052975Z at Module.load (module.js:487:32)

Updating node.js possibly lead to npm error

I recently updated the node.js to the version 6.11.1. Got an error when accessing npm
When I tried to check the version of npm, the following error occurs
$ npm -v
module.js:471
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.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 C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:21
at Object.<anonymous> (C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:92:3)
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)
After getting this error I updated the node.js to the latest version 8.1.4.
and the error is same with different line numbers.
$ npm -v
module.js:487
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:21
at Object.<anonymous> (C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:92:3)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
What is happening? Any fix to this issue?
At last, I got the solution.
I have copied all contents from
C:\Program Files\nodejs\node_modules\npm
and pasted it in
C:\Users\dino\AppData\Roaming\npm\node_modules\npm

Error in ng serve after installing npm angular/cli

I am a beginner in learning nodejs and angular. I have installed node and created a node project which was working fine. Then I did "npm install -g angular-cli" and after that i did ng new client and inside client when i do "ng serve" i am getting the following error:
The "#angular/compiler-cli" package was not properly installed.
Error: The "#angular/compiler-cli" package was not properly installed.
at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\node_modules\#ngtools\webpack\src\index.js:14:11)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\typescript.js:3:17)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\index.js:9:10)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-config.js:4:25)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\tasks\serve.js:11:24)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.run.js:6:15)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Class.run (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.js:67:16)
at Class.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\ember-cli\lib\models\command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:109:7)
You may have older versions.
See the instructions here and see if that helps: https://github.com/angular/angular-cli/wiki/stories-1.0-update
The steps are basically:
Uninstall old version
Update node/npm if necessary
Install new version
The link provides specifics for each of these steps along with appropriate commands.
Run these two commands:
npm uninstall --save-dev angular-cli
npm install --save-dev #angular/cli#latest
Here is a simple solution to that and it works like charm.
cd into your project directory cd client.
Run npm install or yarn install, wait for it to successfully execute
Run your ng serve.
I hope this helps and much more easier
Try to run this : npm install --save-dev #angular/cli#latest

NodeJS Error: Module version mismatch. Expected 48, got 46

After I upgraded NodeJS and NPM to 6.2.0 and 3.9.3, when I run hexo d -g command to update my blog, I get the following error:
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/Debug/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.
I thought maybe Node.js is upgraded and node_modules should be reinstalled.
I tried rm -rf node_modules && npm install, but it doesn't work. I also tried sudo npm i -g npm then npm install hexo --no-optional --save, which doesn't work neither.
Any advice would be most appreciated.
Actually, after upgrading node, your installed packages kept compiled against the older version, and they need to be rebuilt. No need to delete node_modules, or running npm update.
Just run:
npm rebuild
Hexo doesn't seem to work with lastest version of node which is 6.2.0. You should use node-v4.4.5 (LTS) for a while, which is recommended version for most users.
It looks like hexo is a globally installed package, but you only reinstalled it locally. Try to reinstall it globally:
npm install hexo -g
Maybe your Global installation files has not been update, please try to update your hexo-cli with command below:
sudo npm install -g hexo-cli
which solved my problem.

Resources