Cannot find the module. / models / config '

Update my Angular 2 CLI project from 1.0.0-beta.11-webpack.2to 1.0.0-beta.11-webpack.8 according to the instructions :

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@webpack    

led to the following:

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)
+4
source share
2 answers

When installing the 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 Angular CLI Project

npm install --save-dev angular-cli@latest

Update project configuration files

ng init

and carefully review each difference.

+3
source

Angular 2 recently changed the build mechanism from SystemJS to Webpack in the latest version. This may be one (among others) of the reasons for this error message (it was for me anyway).

, , git, :

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@latest //in theory, npm install -g angular-cli should be OK

, , "", , node_modules :

rm -rf node_modules
npm install

:

ng build
+2

Source: https://habr.com/ru/post/1654615/


All Articles