2

I upgraded angular to 4 and angular cli to 1.03. After I run the command npm ls typescript I get:

+-- @angular/[email protected]
| `-- [email protected]
`-- [email protected]  invalid

npm ERR! invalid: [email protected] C:\development\projects-git\mydoc\static-web\node_modules\typescript

What's the difference between the first and the second typescript, why is the second one invalid/how do I fix it?

I think the error above is the reason why I get the error below so I hope there is a fix for both so I can run my application again.

ERROR in AppModule is not an NgModule
ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
    at Object.getNewLineCharacter (..\static-web\node_modules\typescript\lib\typescript.js:9580:20)
    at Object.createCompilerHost (..\static-web\node_modules\typescript\lib\typescript.js:66674:26)
    at Object.ngcLoader (..\static-web\node_modules\@ngtools\webpack\src\loader.js:202:31)
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

1 Answer 1

5

I had a similar issue where i even had two different typescript versions listed when i did npm ls typescript.

What's the difference between the first and the second typescript

The first one is listed as a dependency of @angular/cli, the second one is a dependency of your own project.

why is the second one invalid/how do I fix it?

In my case, i had typescript defined under both, dependencies and devDependencies section in my package.json. I removed it from dependencies and the duplicate output disappeared.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks already did that by now but it seems that it wasn't the origin of the error.
Instead of upgrading your cli-project, you could try to generate a new one with ng new new-project, copy your src folder (and package.json deps) over and try whether your error persists. If not, take the newly generated configuration files over into your existing project. This solution is easier on smaller projects without lots of customizations, but it may be worth a try even for a more complex scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.