When trying to run npm start, I get the error:
Error: EACCES: permission denied, open '/root/.pm2/module_conf.json'
at Object.openSync (node:fs:582:3)
at Object.readFileSync (node:fs:450:35)
at Object.Configuration.getAllSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:299:26)
at Object.Configuration.getSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:270:30)
at new API (/usr/local/lib/node_modules/pm2/lib/API.js:117:44)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
/usr/local/lib/node_modules/pm2/node_modules/#pm2/agent/src/InteractorClient.js:58
if (stats.uid === 0) {
^
TypeError: Cannot read property 'uid' of undefined
at /usr/local/lib/node_modules/pm2/node_modules/#pm2/agent/src/InteractorClient.js:58:21
at FSReqCallback.oncomplete (node:fs:195:21)
the command in package.json looks like this
{
"scripts": {
"start": "pm2 start ./node_modules/laravel-echo-server/dist/index.js"
},
"dependencies": {
"laravel-echo-server": "^1.6.2",
"save": "^2.4.0"
}
}
But if I run the command in the terminal
pm2 start ./node_modules/laravel-echo-server/dist/index.js
it works fine
/app # pm2 start ./node_modules/laravel-echo-server/dist/index.js
[PM2] Starting /app/node_modules/laravel-echo-server/dist/index.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1 │ index │ default │ 1.6.2 │ fork │ 13626 │ 0s │ 0 │ online │ 0% │ 7.6mb │ root │ disabled │
│ 0 │ laravelEcho │ default │ 1.6.2 │ fork │ 13608 │ 1s │ 1207 │ online │ 0% │ 69.6mb │ root │ disabled │
└─────┴────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. Type 'pm2 save' to synchronize.
After searching the internet for a solution to the problem, I saw a possible solution, but it didn't work for me either.
This solution was to create an ecosystem.config.js file
here is an example with this solution but it doesn't work either
package.json
{
"scripts": {
"start": "pm2 start ecosystem.config.js"
},
"dependencies": {
"laravel-echo-server": "^1.6.2",
"save": "^2.4.0"
}
}
ecosystem.config.js
module.exports = {
apps : [
{
name: "laravelEcho",
script: "./node_modules/laravel-echo-server/dist/index.js",
args : "start"
}
]
}
Perhaps this will help when looking for the problem, I am using Docker
Dockerfile
FROM node:alpine
WORKDIR /app
RUN npm install pm2:2.9.2 -g && pm2 update
EXPOSE 8888
What could be the problem?
not sure it's great to run it as root, have a look here on pm2s git repo on user access: Starting PM2 as a non-root user is broken
i think you can fix the "permission denied" with running this as su so just run sudo npm start but because i can't code in js i can't help you with the errors i'm sorry!:/
I hope i could help you anyways a little bit!!
I am getting this error, verdaccio just crashed and no longer working after a server restart. When I try to pm2 start verdaccio , I get the following error
Error: Cannot find module '/home/ec2-user/verdaccio'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:53:21)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
npm config ls
; cli configs
scope = ""
user-agent = "npm/4.2.0 node/v7.10.0 linux x64"
; userconfig /home/ec2-user/.npmrc
http-proxy = null
https-proxy = null
registry = "https://registry.npmjs.org/"
strict-ssl = false
; globalconfig /usr/etc/npmrc
registry = "https://registry.npmjs.org/"
; node bin location = /usr/bin/node
; cwd = /home/ec2-user/verdaccio
; HOME = /home/ec2-user
; "npm config ls -l" to show all defaults.
pm2 show verdaccio
│ name │ verdaccio │
│ restarts │ 255 │
│ uptime │ 0 │
│ script path │ /home/ec2-user/verdaccio │
│ script args │ N/A │
│ error log path │ /home/ec2-user/.pm2/logs/verdaccio-error-0.log │
│ out log path │ /home/ec2-user/.pm2/logs/verdaccio-out-0.log │
│ pid path │ /home/ec2-user/.pm2/pids/verdaccio-0.pid │
│ interpreter │ node │
│ interpreter args │ N/A │
│ script id │ 0 │
│ exec cwd │ /home/ec2-user │
│ exec mode │ fork_mode │
│ node.js version │ 7.10.0 │
│ watch & reload │ ✘ │
│ unstable restarts │ 0 │
│ created at │ N/A
`
My config file is as follows:
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'av-*':
allow_access: $all
allow_publish: $all
'*':
allow_access: $all
allow_publish: $all
proxy: npmjs
'#*/*':
allow_access: $all
allow_publish: $authenticated
proxy: npmjs
https:
key: /home/ec2-user/verdaccio/verdaccio-keynew.pem
cert: /home/ec2-user/verdaccio/verdaccio-certnew.pem
ca: /home/ec2-user/verdaccio/server.ca
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: verdaccio.log, level: info}
listen:
- https://devnpm2:4873
max_body_size: 300mb
It can't find the verdaccio executable, to locate it you can use the which command.
To do this you should try:
pm2 start `which verdaccio`
I am trying to write a package for node in TypeScript that uses standard node libraries, for example fs, path, stream, http, and so on.
When I try to import libraries in a .ts file, VS Code marks the corresponding line with an error:
[ts] Cannot find module 'fs'.
This happens no matter how I try to import the library:
import * as fs from 'fs'; // [ts] Cannot find module 'fs'
import fs = require('fs'); // [ts] Cannot find module 'fs'
const fs = require('fs'); // [ts] Cannot find name 'require'
I (should) have the correct definitions installed with typings install --save --ambient node.
When I compile to JavaScript (using gulp and gulp-typescript, not tsc), the compliation works and the syntax highlighting shows no errors until I type in 1 character again:
How can I correctly define the node libraries for TypeScript?
I use VS Code for code highlighting and autocompletion, gulp & gulp-typescript to compile and typings for the typescript library declarations.
The project's directory structure:
├─ build/
│ └─ (output files)
├─ src/
│ └─ myfile.ts
├─ typings/
│ ├─ browser/
│ │ └─ ambient/
│ │ └─ node/
│ │ └─ index.d.ts
│ ├─ main/
│ │ └─ ambient/
│ │ └─ node/
│ │ └─ index.d.ts
│ ├─ browser.d.ts
│ └─ main.d.ts
├─ gulpfile.js
├─ package.json
├─ tsconfig.json
└─ typings.json
My tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"declaration": true,
"module": "system",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"target": "es5"
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
]
}
My typings.json:
{
"ambientDependencies": {
"node": "registry:dt/node#4.0.0+20160412142033"
}
}
And my gulp task:
gulp.task('build-typescript', () => {
const gulpts = require('gulp-typescript');
const tsProject = gulpts.createProject('tsconfig.json', {
typescript: require('typescript'),
outFile: 'mylibrary.js',
noLib: true
});
let tsstream = (
gulp.src([
'node_modules/typescript/lib/lib.es6.d.ts',
'typings/main.d.ts',
'src/sharpscript.ts'])
.pipe(sourcemaps.init())
.pipe(gulpts(tsProject))
);
return require('merge2')(
tsstream.dts.pipe(gulp.dest('build')),
tsstream.js
.pipe(sourcemaps.write('.', { includeContent: true }))
.pipe(gulp.dest('build'))
);
});
In case anyone has experienced the same problem, I am thankful for any insights.
the installation of type declarations with 'typings install ...' is obsolete since a few months. The new way is to install it directly via npm and the #types namespace. to install the node type declarations just use npm install #types/node --save-dev.
I'm following this guide
http://mobileangularui.com/blog/your-first-phonegap-app-with-mobile-angular-ui/#why-not-just-twitter-bootstrap-and-angular-ui-
but when i run this code
npm install -g bower yo gulp generator-mobileangularui
I receive this error...
C:\Users\Desktop\Sorgente\weather>npm install -g bower yo gulp
generator-mobileangularui
> npm WARN engine yo#1.4.6: wanted: {"node":">=0.10.0","npm":">=2.1.0"}
(current:
{"node":"v0.10.29","npm":"1.4.14"})
|
> buffertools#2.1.2 install C:\Users\AppData\Roaming\npm\node_m
odules\generator-mobileangularui\node_modules\slug\node_modules\unicode\node_mod
ules\bufferstream\node_modules\buffertools
> node-gyp rebuild
C:\Users\AppData\Roaming\npm\node_modules\generator-mobileangul
arui\node_modules\slug\node_modules\unicode\node_modules\bufferstream\node_modul
es\buffertools>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\
..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere. [C:\Users\AppData\Roaming\npm\node_modules\generator-mobileangularui\node_modules\slug\n
ode_modules\unicode\node_modules\bufferstream\node_modules\buffertools\build\bi
nding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\AppData\Roaming\npm\node_modules\generato
r-mobileangularui\node_modules\slug\node_modules\unicode\node_modules\bufferstre
am\node_modules\buffertools
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
npm WARN optional dep failed, continuing buffertools#2.1.2
|
> unicode#0.6.1 postinstall C:\Users\AppData\Roaming\npm\node_m
odules\generator-mobileangularui\node_modules\slug\node_modules\unicode
> node install.js
try to read file /usr/share/unicode/UnicodeData.txt .
Warning: using slow naiv Buffer.indexOf function!
`npm install buffertools` to speed things up.
/usr/share/unicode/UnicodeData.txt not found.
try to read file /usr/share/unicode-data/UnicodeData.txt .
/usr/share/unicode-data/UnicodeData.txt not found.
try to read file UnicodeData.txt .
UnicodeData.txt not found.
try to download .
GET unicode.org:80/Public/UNIDATA/UnicodeData.txt
fetching .
C:\Users\AppData\Roaming\npm\gulp -> C:\Users\
AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
C:\Users\AppData\Roaming\npm\yo -> C:\Users\Ap
pData\Roaming\npm\node_modules\yo\lib\cli.js
> yo#1.4.6 postinstall C:\Users\AppData\Roaming\npm\node_module
s\yo
> yodoctor
/
Yeoman Doctor
Running sanity checks on your system
V Global configuration file is valid
V NODE_PATH matches the npm root
V No .bowerrc file in home directory
V No .yo-rc.json file in home directory
Everything looks all right!
C:\Users\AppData\Roaming\npm\bower -> C:\Users
\AppData\Roaming\npm\node_modules\bower\bin\bower
gulp#3.8.11 C:\Users\AppData\Roaming\npm\node_modules\gulp
├── interpret#0.3.10
├── pretty-hrtime#0.2.2
├── deprecated#0.0.1
├── archy#1.0.0
├── tildify#1.0.0 (user-home#1.1.1)
├── minimist#1.1.1
├── v8flags#2.0.5 (user-home#1.1.1)
├── semver#4.3.4
├── chalk#0.5.1 (ansi-styles#1.1.0, supports-color#0.2.0, escape-string-regexp#1
.0.3, has-ansi#0.1.0, strip-ansi#0.3.0)
├── orchestrator#0.3.7 (stream-consume#0.1.0, sequencify#0.0.7, end-of-stream#0.
1.5)
├── liftoff#2.0.3 (extend#2.0.1, flagged-respawn#0.3.1, resolve#1.1.6, findup-sy
nc#0.2.1)
├── vinyl-fs#0.3.13 (graceful-fs#3.0.6, strip-bom#1.0.0, vinyl#0.4.6, defaults#1
.0.2, mkdirp#0.5.0, glob-stream#3.1.18, glob-watcher#0.0.6, through2#0.6.5)
└── gulp-util#3.0.4 (array-uniq#1.0.2, array-differ#1.0.0, beeper#1.0.0, lodash.
_reevaluate#3.0.0, object-assign#2.0.0, lodash._reescape#3.0.0, lodash._reinterp
olate#3.0.0, replace-ext#0.0.1, vinyl#0.4.6, chalk#1.0.0, dateformat#1.0.11, lod
ash.template#3.5.1, through2#0.6.5, multipipe#0.1.2)
generator-mobileangularui#1.2.1 C:\Users\AppData\Roaming\npm\no
de_modules\generator-mobileangularui
├── chalk#0.4.0 (ansi-styles#1.0.0, has-color#0.1.7, strip-ansi#0.1.1)
├── yosay#0.1.0 (pad-component#0.0.1, word-wrap#0.1.3, minimist#0.0.9)
├── slug#0.5.0 (unicode#0.6.1)
└── yeoman-generator#0.16.0 (dargs#0.1.0, diff#1.0.8, debug#0.7.4, isbinaryfile#
2.0.4, class-extend#0.1.1, rimraf#2.2.8, async#0.2.10, findup-sync#0.1.3, mime#1
.2.11, text-table#0.2.0, mkdirp#0.3.5, iconv-lite#0.2.11, shelljs#0.2.6, lodash#
2.4.2, underscore.string#2.3.3, glob#3.2.11, file-utils#0.1.5, request#2.30.0, c
heerio#0.13.1, inquirer#0.4.1, download#0.1.19)
yo#1.4.6 C:\Users\AppData\Roaming\npm\node_modules\yo
├── titleize#1.0.0
├── array-uniq#1.0.2
├── figures#1.3.5
├── user-home#1.1.1
├── humanize-string#1.0.1 (decamelize#1.0.0)
├── opn#1.0.2
├── string-length#1.0.0 (strip-ansi#2.0.1)
├── async#0.9.0
├── sort-on#1.2.0 (dot-prop#2.0.0)
├── yeoman-character#1.0.1 (supports-color#1.3.1)
├── cross-spawn#0.2.9 (lru-cache#2.6.2)
├── findup#0.1.5 (commander#2.1.0, colors#0.6.2)
├── root-check#1.0.0 (downgrade-root#1.1.0, sudo-block#1.2.0)
├── yosay#1.0.3 (ansi-styles#2.0.1, word-wrap#1.0.3, ansi-regex#1.1.1, strip-ans
i#2.0.1, pad-component#0.0.1, taketalk#1.0.0, minimist#1.1.1)
├── chalk#1.0.0 (escape-string-regexp#1.0.3, ansi-styles#2.0.1, supports-color#1
.3.1, strip-ansi#2.0.1, has-ansi#1.0.3)
├── meow#3.1.0 (object-assign#2.0.0, camelcase-keys#1.0.0, indent-string#1.2.1,
minimist#1.1.1)
├── update-notifier#0.3.2 (is-npm#1.0.0, latest-version#1.0.0, semver-diff#2.0.0
)
├── npm-keyword#1.1.1 (registry-url#3.0.3)
├── package-json#1.1.0 (registry-url#3.0.3)
├── got#2.9.2 (lowercase-keys#1.0.0, is-stream#1.0.1, timed-out#2.0.0, prepend-h
ttp#1.0.1, nested-error-stacks#1.0.0, infinity-agent#2.0.3, statuses#1.2.1, obje
ct-assign#2.0.0, read-all-stream#2.1.2, duplexify#3.3.0)
├── fullname#1.1.0 (npmconf#2.1.1)
├── configstore#0.3.2 (xdg-basedir#1.0.1, object-assign#2.0.0, osenv#0.1.0, grac
eful-fs#3.0.6, uuid#2.0.1, mkdirp#0.5.0, js-yaml#3.3.0)
├── insight#0.5.3 (object-assign#2.0.0, lodash.debounce#3.0.3, tough-cookie#0.12
.1, os-name#1.0.3, request#2.55.0)
├── yeoman-doctor#1.3.2 (object-values#1.0.0, log-symbols#1.0.2, each-async#1.1.
1, twig#0.7.2)
├── yeoman-environment#1.2.5 (untildify#2.0.0, log-symbols#1.0.2, escape-string-
regexp#1.0.3, diff#1.4.0, text-table#0.2.0, debug#2.1.3, grouped-queue#0.3.0, gl
obby#1.2.0, mem-fs#1.1.0)
├── lodash#3.8.0
└── inquirer#0.8.3 (cli-width#1.0.1, ansi-regex#1.1.1, through#2.3.7, readline2#
0.1.1, rx#2.5.2)
bower#1.4.1 C:\Users\AppData\Roaming\npm\node_modules\bower
├── is-root#1.0.0
├── junk#1.0.1
├── stringify-object#1.0.1
├── chmodr#0.1.0
├── which#1.0.9
├── abbrev#1.0.5
├── rimraf#2.3.3
├── user-home#1.1.1
├── lockfile#1.0.0
├── opn#1.0.2
├── bower-logger#0.2.2
├── bower-endpoint-parser#0.2.2
├── graceful-fs#3.0.6
├── archy#1.0.0
├── nopt#3.0.1
├── retry#0.6.1
├── lru-cache#2.6.2
├── semver#2.3.2
├── p-throttler#0.1.1 (q#0.9.7)
├── tmp#0.0.24
├── request-progress#0.3.1 (throttleit#0.0.2)
├── q#1.3.0
├── shell-quote#1.4.3 (array-filter#0.0.1, array-reduce#0.0.0, array-map#0.0.0,
jsonify#0.0.0)
├── chalk#1.0.0 (escape-string-regexp#1.0.3, ansi-styles#2.0.1, supports-color#1
.3.1, strip-ansi#2.0.1, has-ansi#1.0.3)
├── mkdirp#0.5.0 (minimist#0.0.8)
├── promptly#0.2.0 (read#1.0.5)
├── bower-json#0.4.0 (intersect#0.0.3, deep-extend#0.2.11, graceful-fs#2.0.3)
├── insight#0.5.3 (object-assign#2.0.0, lodash.debounce#3.0.3, async#0.9.0, toug
h-cookie#0.12.1, os-name#1.0.3)
├── glob#4.5.3 (once#1.3.2, inflight#1.0.4, inherits#2.0.1, minimatch#2.0.7)
├── fstream#1.0.5 (inherits#2.0.1)
├── fstream-ignore#1.0.2 (inherits#2.0.1, minimatch#2.0.7)
├── cardinal#0.4.4 (ansicolors#0.2.1, redeyed#0.4.4)
├── decompress-zip#0.1.0 (mkpath#0.1.0, touch#0.0.3, binary#0.3.0, readable-stre
am#1.1.13)
├── tar-fs#1.5.0 (pump#1.0.0, tar-stream#1.1.4)
├── github#0.2.4 (mime#1.3.4)
├── request#2.53.0 (caseless#0.9.0, forever-agent#0.5.2, aws-sign2#0.5.0, tunnel
-agent#0.4.0, oauth-sign#0.6.0, json-stringify-safe#5.0.0, isstream#0.1.2, strin
gstream#0.0.4, qs#2.3.3, node-uuid#1.4.3, combined-stream#0.0.7, mime-types#2.0.
11, form-data#0.2.0, http-signature#0.10.1, hawk#2.3.1, tough-cookie#1.1.0, bl#0
.9.4)
├── update-notifier#0.3.2 (is-npm#1.0.0, string-length#1.0.0, semver-diff#2.0.0,
latest-version#1.0.0)
├── bower-registry-client#0.3.0 (rimraf#2.2.8, request-replay#0.2.0, graceful-fs
#2.0.3, lru-cache#2.3.1, mkdirp#0.3.5, async#0.2.10, request#2.51.0)
├── mout#0.11.0
├── handlebars#2.0.0 (optimist#0.3.7, uglify-js#2.3.6)
├── bower-config#0.6.1 (osenv#0.0.3, graceful-fs#2.0.3, optimist#0.6.1, mout#0.9
.1)
├── configstore#0.3.2 (object-assign#2.0.0, xdg-basedir#1.0.1, osenv#0.1.0, uuid
#2.0.1, js-yaml#3.3.0)
└── inquirer#0.8.0 (figures#1.3.5, ansi-regex#1.1.1, mute-stream#0.0.4, through#
2.3.7, readline2#0.1.1, chalk#0.5.1, lodash#2.4.2, rx#2.5.2, cli-color#0.3.3)
C:\Users\Desktop\Sorgente\weather>yo mobileangularui
Error: Cannot find module 'unicode/category/So'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at symbols (C:\Users\AppData\Roaming\npm\node_modules\gener
ator-mobileangularui\node_modules\slug\slug.js:6:16)
at C:\Users\AppData\Roaming\npm\node_modules\generator-mobi
leangularui\node_modules\slug\slug.js:123:5
at Object.<anonymous> (C:\Users\AppData\Roaming\npm\node_mo
dules\generator-mobileangularui\node_modules\slug\slug.js:130:2)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
I installed the .NET Framework 2.0 SDK but I have the same problem...How can fix it???
My versions:
C:\Users\bla>npm -v
1.4.14
C:\Users\bla>node -v
v0.10.29
C:\Users\bla>cordova -v
4.3.0
Try running:
node-gyp rebuild --msvs-version=2012
Also works with:
--msvs-version=2013