Running Express js server with pnpm in container gives permission error during start like this:
> pnpm run --filter=#workspace/mypackage dev
> #workspace/mypackage#1.0.0 dev /app/packages/mypackage
> nodemon
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node ./src/index.ts`
sh: ts-node: Permission denied
[nodemon] app crashed - waiting for file changes before starting...
pnpm unsafe-perm is already set true and corepack enabled.
My package json looks like this:
...
"scripts": {
"dev": "nodemon"
},
...
"dependencies": {
"express": "^4.18.2"
},
"devDependencies": {
"nodemon": "^2.0.20",
"ts-node": "^10.9.1"
}
Update: just found that ts-node is not installed during build by testing ts-node in the last step of docker build. So the problem turns out to be why pnpm didn't install dev dependency of a package which is ts-node.
Docker build logs:
#14 [stage-1 7/8] RUN ts-node -e 'console.log("Hello, world!")'
#14 sha256:e75e2e17e660efaa7407c1bbeaf48e9d7d4ac754facc168f35cdd1f51ff00b91
#14 0.346 /bin/sh: ts-node: not found
#14 ERROR: executor failed running [/bin/sh -c ts-node -e 'console.log("Hello, world!")']: exit code: 127
------
> [stage-1 7/8] RUN ts-node -e 'console.log("Hello, world!")':
------
executor failed running [/bin/sh -c ts-node -e 'console.log("Hello, world!")']: exit code: 127
Related
I'm trying to start my server with nodemon, but it crashes with the following output.
The error ERROR: Unrecognized environment. Aborting. seems quite rare, from a Google search.
Ran the same code in Windows 10 and a WSL2 Ubuntu set up. Both had the same results. The server does start for my coworker for some reason, though.
user#LAPTOP:~/myproject$ npm run start:dev
> myproject#0.0.0 start:dev /home/user/myproject
> nodemon
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts,html
[nodemon] starting `./node_modules/.bin/ts-node -r tsconfig-paths/register ./src`
[2021-03-23T04:11:42.704Z] ERROR: Unrecognized environment. Aborting.
[nodemon] app crashed - waiting for file changes before starting...
^C
user#LAPTOP:~/myproject$ npm -v
6.14.11
user#LAPTOP:~/myproject$ node -v
v15.12.0
This is a bug with my sequelize code
The issue came from trying to access the sequelize.js database before connecting to it.
Moving my Model.findAll() statement to after the app has launched has fixed the issue.
After running the install script, the server starts and serves a page displaying the same text after the 'Failed to compile line.'
I'm running Windows 10 and auto update just updated my pc today, right before I did the create-react-express install.
PS H:\mern-passport> npm start
> mern#1.0.0 start H:\mern-passport
> if-env NODE_ENV=production && npm run start:prod || npm run start:dev
> mern#1.0.0 start:dev H:\mern-passport
> concurrently "nodemon --ignore 'client/*'" "npm run client"
[0] [nodemon] 1.19.4
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching dir(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node server.js`
[0] API server now on port 3001!
[1]
[1] > mern#1.0.0 client H:\mern-passport
[1] > cd client && npm run start
[1]
[1]
[1] > mern#0.1.0 start H:\mern-passport\client
[1] > react-scripts start
[1]
[1] Starting the development server...
[1]
[1] Failed to compile.
[1]
[1] ./src/index.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
[1] Error: Package exports for 'H:\mern-passport\client\node_modules\autoprefixer\node_modules\kleur' do not define a valid './colors' target
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
Seems to be an issue with autoprefixer latest version. I referred https://github.com/postcss/autoprefixer/issues/1328 and tried downgrading autoprefixer in my project and it works now.
Try:
npm install autoprefixer#9.8.0
Happy coding!
I also faced this problem. And it looks like a problem with autoprefixer version, so i changed the version.
npm install autoprefixer#9.8.0
I tried this, and it works perfectly.
I was running into this issue too. I installed yarn and created a new project with the npx create-react-app command and this fixed the issue.
I found one project on GitHub darkwire and wanted to install it and play with it. Firstly I tried to install it from windows. I installed Node.js and Yarn and I got errors with the command: yarn dev
`C:\darkwire.io-master>yarn dev
yarn run v1.21.1
$ concurrently 'cd client && yarn start' 'cd server && yarn dev'
[0] 'c' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] 'client' is not recognized as an internal or external command,
[1] operable program or batch file.
[0] c exited with code 1
[1] client exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`
My next step was to try it in ubuntu 19.10, firstly I installed again Node.js and Yarn and again used: yarn dev. I got an error but now was open site and it not working, just say "Disconnected"
```qq#ubuntu:~/Downloads/darkwire.io-master$ yarn dev
yarn run v1.21.1
$ concurrently 'cd client && yarn start' 'cd server && yarn dev'
$ nodemon src/index.js --exec babel-node
$ react-scripts start
[1] [nodemon] 1.19.0
[1] [nodemon] to restart at any time, enter `rs`
[1] [nodemon] watching: *.*
[1] [nodemon] starting `babel-node src/index.js`
[1] Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[1] Checking for inactive rooms...
[1] Darkwire is online at port 3001
[1] events.js:183
[1] throw er; // Unhandled 'error' event
[1] ^
[1]
[1] Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
[1] at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
[1] [nodemon] app crashed - waiting for file changes before starting...
[0] Starting the development server...
[0]
[0] Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[0] Compiled successfully!
[0]
[0] You can now view darkwire-client in the browser.
[0]
[0] Local: http://localhost:3000/
[0] On Your Network: http://175.124.13.111:3000/
[0]
[0] Note that the development build is not optimized.
[0] To create a production build, use yarn build.
[0]
```
screenshot
I think maybe I have the wrong version Node.js and try install 9.x version, download again project and try again, it not help, try change port from 3001 to 3000, not help.
From their README.md
Darkwire Server
Darkwire server is a Node.js application that requires redis.
So please install a compatible redis server. Redis tutorial
I have an application running on a node server. The application is running fine, but unfortunately I do not see any logs in the terminal window. When I do npm start, I get the following output in the terminal:
> app#0.1.0 start /Users/prerak/WebProjects/app/www
> grunt
Running "jshint:all" (jshint) task
Running "csslint:all" (csslint) task
Warning: Unable to read ".csslintrc" file (Error code: ENOENT). Used --force, continuing.
Running "concurrent:default" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js`
I have some calls to console.log in my server.js file but I do not see them in the terminal. Is there anything else that I can do to get the logs?
For the application without any errors it's fine but if there are any issues, it's very difficult to debug the issue. In case of an error, I get the following in the logs:
> app#0.1.0 start /Users/prerak/WebProjects/app/www
> grunt
Running "jshint:all" (jshint) task
Running "csslint:all" (csslint) task
Warning: Unable to read ".csslintrc" file (Error code: ENOENT). Used --force, continuing.
Running "concurrent:default" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js
[nodemon] app crashed - waiting for file changes before starting...
I do not get any stackstace of the issue.
I have also configured my express server to show the stacktrace as:
var app = express();
app.set('showStackError', true);
I have this issue on Mac OSX 10.12 but if I run the same code on Ubuntu 14.10, it shows the logs in the terminal.
Also, instead of npm start if I do node server.js it shows the logs. What can be the reason behind this?
I am starting my node application using grunt command. My Gruntfile.js is:
module.exports = function(grunt) {
grunt.initConfig({
nodemon: {
dev: {
script: 'server.js'
}
},
watch: {
css: {
files: ['src/css/*.scss'],
tasks: ['sass:dev']
},
js: {
files: ['src/js/*.js'],
tasks: ['uglify:dev']
}
},
concurrent: {
options: {
logConcurrentOutput: true
},
tasks: ['nodemon','watch']
}
});
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default',['concurrent']);
};
When I run the application typing grunt I get the following output:
C:\Projects\SocialMeal>grunt
Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Then every console.log() call at server.js is not shown. If I start the app using node server.js the console.log() messages are shown.
Any hint?
Found it thanks to greuze. The problem was nodemon version. Changed it to 1.11.0 and the console.log outputs works now.
Simply removed the current version installed:
npm uninstall grunt-nodemon
And changed package.json:
"grunt-nodemon": "~1.10.0",
I do get console.log outputs.
I have an server.js file with content:
let name = 'Peter';
console.log(`My name is: ${name}`);
I used your Gruntfile.js.
I get this output after running grunt:
Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
My name is: Peter
[nodemon] clean exit - waiting for changes before restart
Note that there is the console.log output. Are you sure your process is not stuck anywhere?