Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix npm failing to globally install typescript error

When attempting to install typescript globally using npm

sudo npm install -g typescript

The installation fails and I am presented the following error:

ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/typescript/bin/tsc'

The full contents of the log are

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'typescript' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 631fb36c24f0a08c
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/typescript 3969ms (from cache)
8 silly pacote tag manifest for typescript@latest fetched in 4025ms
9 timing stage:loadCurrentTree Completed in 4299ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule [email protected] checking installable status
17 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 5ms
18 timing stage:loadIdealTree Completed in 7ms
19 silly currentTree lib
20 silly idealTree lib
20 silly idealTree └── [email protected]
21 silly install generateActionsToTake
22 timing stage:generateActionsToTake Completed in 4ms
23 silly diffTrees action count 1
24 silly diffTrees add [email protected]
25 silly decomposeActions action count 8
26 silly decomposeActions fetch [email protected]
27 silly decomposeActions extract [email protected]
28 silly decomposeActions preinstall [email protected]
29 silly decomposeActions build [email protected]
30 silly decomposeActions install [email protected]
31 silly decomposeActions postinstall [email protected]
32 silly decomposeActions finalize [email protected]
33 silly decomposeActions refresh-package-json [email protected]
34 silly install executeActions
35 silly doSerial global-install 8
36 verbose correctMkdir /Users/user/.npm/_locks correctMkdir not in flight; initializing
37 verbose lock using /Users/user/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
38 silly doParallel extract 1
39 silly extract [email protected]
40 timing action:extract Completed in 602ms
41 silly doReverseSerial unbuild 8
42 silly doSerial remove 8
43 silly doSerial move 8
44 silly doSerial finalize 8
45 silly finalize /usr/local/lib/node_modules/typescript
46 timing action:finalize Completed in 3ms
47 silly doParallel refresh-package-json 1
48 silly refresh-package-json /usr/local/lib/node_modules/typescript
49 timing action:refresh-package-json Completed in 14ms
50 silly doParallel preinstall 1
51 silly preinstall [email protected]
52 info lifecycle [email protected]~preinstall: [email protected]
53 timing action:preinstall Completed in 1ms
54 silly doSerial build 8
55 silly build [email protected]
56 info linkStuff [email protected]
57 silly linkStuff [email protected] has /usr/local/lib/node_modules as its parent node_modules
58 silly linkStuff [email protected] is part of a global install
59 silly linkStuff [email protected] is installed into a global node_modules
60 silly linkStuff [email protected] is installed into the top-level global node_modules
61 verbose linkBins [ { tsc: './bin/tsc', tsserver: './bin/tsserver' },
61 verbose linkBins   '/usr/local/bin',
61 verbose linkBins   true ]
62 timing action:build Completed in 3ms
63 verbose unlock done using /Users/user/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
64 timing stage:rollbackFailedOptional Completed in 16ms
65 timing stage:runTopLevelLifecycles Completed in 4956ms
66 verbose stack Error: ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/typescript/bin/tsc'
67 verbose cwd /Users/user/localserver
68 verbose Darwin 18.2.0
69 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "typescript"
70 verbose node v8.11.4
71 verbose npm  v6.5.0
72 error path /usr/local/lib/node_modules/typescript/bin/tsc
73 error code ENOENT
74 error errno -2
75 error syscall chmod
76 error enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/typescript/bin/tsc'
77 error enoent This is related to npm not being able to find a file.
78 verbose exit [ -2, true ]

Any help would be much apreciated!

like image 520
Rafi Levy Avatar asked Nov 07 '22 22:11

Rafi Levy


1 Answers

I fixed this by reinstalling Node JS from online.

After this typescript installed with no errors.

like image 150
Rafi Levy Avatar answered Nov 14 '22 09:11

Rafi Levy