ng-toolkit: Module not found: Error: Can't resolve './/server/main'
Any idea why I am getting this error I dont have any additional changes on this I just install ng-toolkit after npm run build:prod the result is this. Thanks in advance
WARNING in ./node_modules/@angular/core/fesm5/core.js System.import() is deprecated and will be removed soon. Use import() instead. For more info visit https://webpack.js.org/guides/code-splitting/ @ ./server.ts 4826:15-36 5:13-37
WARNING in ./node_modules/@angular/core/fesm5/core.js System.import() is deprecated and will be removed soon. Use import() instead. For more info visit https://webpack.js.org/guides/code-splitting/ @ ./server.ts 4838:15-102 5:13-37
WARNING in configuration The ‘mode’ option has not been set, webpack will fallback to ‘production’ for this value. Set ‘mode’ option to ‘development’ or ‘production’ to enable defaults for each environment. You can also set it to ‘none’ to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/
ERROR in ./server.ts
Module not found: Error: Can’t resolve ‘.//server/main’ in ‘d:\tosh-wot-angular’
@ ./server.ts 19:9-34
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! wot@0.0.0 build:server:prod: ng run wot:server && webpack --config webpack.server.config.js --progress --colors
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the wot@0.0.0 build:server:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Lenovo\AppData\Roaming\npm-cache_logs\2018-06-13T09_42_06_176Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! wot@0.0.0 build:prod: npm run build:server:prod && npm run build:browser:prod
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the wot@0.0.0 build:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Lenovo\AppData\Roaming\npm-cache_logs\2018-06-13T09_42_06_441Z-debug.log
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 20 (4 by maintainers)
Hey. Your project is not in latest Angular.
@ng-toolkit
supports Angular 6+. Please update to the latest Angular version 😃Angular 8 here, same issue. Not sure if it matters, but when I ran
ng add @ng-toolkit/universal
I had a ton of ts errors (mostly implicitany
s and unused references) in the generatedserver.ts
andprerender.ts
files.In your
webpack.server.config.js
(temporary solution)replace
with this
everything worked fine with me. I got rid of the error -
Cannot find module 'require("./server/main")'
by correcting code in the ‘server.js’ file.module.exports = require("require(\"./server/main\")");
tomodule.exports = require('./server/main');
i used ‘ng-toolkit/universal’ and after running ‘npm run server’ i got same error.I am also facing the same issue with Angular-6
I’m also facing the same issue with @ng-toolkit/universal.
@LegolasTheElves There is lack of
angular.json
file in your repository. Please, push it. Thanks in advance!Please refer to this https://github.com/LegolasTheElves/wordoftravel/tree/wotWithToolkit
This is the debug log
0 info it worked if it ends with ok 1 verbose cli [ ‘C:\Program Files\nodejs\node.exe’, 1 verbose cli ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’, 1 verbose cli ‘run’, 1 verbose cli ‘build:server:prod’ ] 2 info using npm@5.6.0 3 info using node@v8.11.1 4 verbose run-script [ ‘prebuild:server:prod’, 4 verbose run-script ‘build:server:prod’, 4 verbose run-script ‘postbuild:server:prod’ ] 5 info lifecycle wot@0.0.0~prebuild:server:prod: wot@0.0.0 6 info lifecycle wot@0.0.0~build:server:prod: wot@0.0.0 7 verbose lifecycle wot@0.0.0~build:server:prod: unsafe-perm in lifecycle true 8 verbose lifecycle wot@0.0.0~build:server:prod: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\tosh-wot-angular\node_modules.bin;C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\tosh-wot-angular\node_modules.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Lenovo\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Git\cmd;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\WINDOWS\System32\OpenSSH;C:\Users\Lenovo\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Lenovo\AppData\Roaming\npm 9 verbose lifecycle wot@0.0.0~build:server:prod: CWD: D:\tosh-wot-angular 10 silly lifecycle wot@0.0.0~build:server:prod: Args: [ ‘/d /s /c’, 10 silly lifecycle ‘ng run wot:server && webpack --config webpack.server.config.js --progress --colors’ ] 11 silly lifecycle wot@0.0.0~build:server:prod: Returned: code: 2 signal: null 12 info lifecycle wot@0.0.0~build:server:prod: Failed to exec build:server:prod script 13 verbose stack Error: wot@0.0.0 build:server:prod:
ng run wot:server && webpack --config webpack.server.config.js --progress --colors
13 verbose stack Exit status 2 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at EventEmitter.emit (events.js:214:7) 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at ChildProcess.emit (events.js:214:7) 13 verbose stack at maybeClose (internal/child_process.js:925:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 14 verbose pkgid wot@0.0.0 15 verbose cwd D:\tosh-wot-angular 16 verbose Windows_NT 10.0.17134 17 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “run” “build:server:prod” 18 verbose node v8.11.1 19 verbose npm v5.6.0 20 error code ELIFECYCLE 21 error errno 2 22 error wot@0.0.0 build:server:prod:ng run wot:server && webpack --config webpack.server.config.js --progress --colors
22 error Exit status 2 23 error Failed at the wot@0.0.0 build:server:prod script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 2, true ]I’m am using ng-toolkit/universal?