Jan Nielsen
Jan Nielsen

Reputation: 11799

Cannot find module './models/config'

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)

Upvotes: 4

Views: 6017

Answers (2)

Jan Nielsen
Jan Nielsen

Reputation: 11799

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.

Upvotes: 4

benscabbia
benscabbia

Reputation: 18072

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

Upvotes: 2

Related Questions