I am using simple ssh deploy action and i have a bash script to build and restart pm2 frontend process.
It's working fine when I run it directly run the script through the ec2 instance but gives error when building through the github action
below is the generated error
It says Failed to load next.config.js but its there, I've printed out pwd to make sure its the correcy directory. But still the same error
Node -> 14.17.0
Next -> 12.0.8
npm -> 6.14.3
out: /home/***/elfswap/elfswap-frontend
out:
out: > fe-elf# build /home/***/elfswap/elfswap-frontend
out: > next build
out:
err: error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
err:
err: > Build error occurred
err: Error: Not supported
err: at Object.loadConfig [as default] (/home/***/elfswap/elfswap-frontend/node_modules/next/dist/server/config.js:413:78)
#!/bin/bash
cd /home/ubuntu/project/frontend
git pull origin master
echo "$(pwd)"
npm run build
pm2 restart frontend
Looking back at it with a fresh mind, figured out the problem.
I already knew that remote ssh doesn't load the bash profile, but node command was working fine so i didn't look much further.
but after echoing node version in the bash script, found out it was using version 8.. from /usr/local/bin not the one installed through nvm.
So to make it work, I removed npm, node binaries from /usr/local/bin and replaced those with symbolic links from nvm version directory.
Now its working fine.
I'm trying to make a discord bot with the command prefix "*" but when I try to get the bot online/run it, it gives me this error:
node:internal/modules/cjs/loader:936
node:internal/modules/cjs/loader:936 throw err; ^
Error: Cannot find module 'C:\Users\name\const'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
The module I'm using is discord.js and i've installed discord.js on CMD and the VSC terminal but it still comes up with the MODULE NOT FOUND error. I've looked around the internet and I can't find one that fixes the problem. I've tried reinstalling Node.js but it won't stop coming back. Please help, Thanks!
same error with me but I just change file dir cause I run node <filename.js> in the wrong dir so I just change like ---
the first step chacks you are in the right dir or not type: > ls
then if you are in the right dir then type: node <filename.js> if not then change your dir to change dir type: cd <filename>
and then run your first app or file for run type: node <filename.js>
I hope your error is solved!
you need to run it as an administrator so sudo(whatever you tryna run) as long as you are in the right directory
On Windows I solved it like this.
I went to the folder: C:\Users\Documents\AppData\Roaming\npm
And I deleted the file. create-react-app.
I started the project again, and it worked.
root cause, my path was messed up, but I only figured that out once I found where my npm packages where. I had thought they were in ../Programs/Roaming/npm etc but since an update (I think to node) my packages were actually in a Python Lib subdir.
Your Answer might be the same as mine, and I found out all this by using the
npm list -g
Command - which showed the globally installed packages, but also highlighted that this was nowhere to be found in my path
Hope this helps someone!
I had the same error and it was a case of trying to run the file in node from the wrong location.
My solution was to use the terminal and CD into the exact folder the file I was trying to run were and then after that I could run node filename.js.
In my case (this error ocurred at running docker container of next app), it was because I was running docker-compose without the flag --build, but of without copy lock files (package-lock.json and/or yarn.lock).
I updated my Dockerfile:
[...]
COPY yarn.lock .
RUN yarn install --frozen-lockfile
CMD [ "yarn", "dev" ]
And after, run with docker-compose up --build
When I was following a JS tutorial i got this error message too.
The problem was I copied an existing JS file and renamed it but it
through that error when i ran it.
When i created a new JS file, and copied the code in, and ran, it worked.
Before starting your server you need to make sure that the start file is mentioned below
cross-env NODE_ENV=production node index<start file name eg:index for index.js>
It happens when you run npm run start without getting into the project first... So, before starting to compile your project, run this command: cd <project folder name>...
It will stop showing the "Missing Module" Error and smoothly run your desired output in your browser
When was trying to find 'npm' & 'Rdme' path from command prompt to update the Rdme was getting this error Log
This error is caused when file can't be found or its a wrong path, In my case I added the missing file to respective folders- configured & updated in Environment variables (after adding missing files)
For the coming next. For me I'v got the error when I tried to run a package.json script with the npx run rather npm run.
In my case, I used chocolatey to install nodejs and it fixed my issue.
Open an Administrator Command Prompt (right click Command Prompt and select "Run as Administrator"), then run the following command:
choco install -y nodejs-lts
I hope it works for you too :)
The error tells that you've required packages that you haven't installed. So please make sure that you've installed every package that you've required in your bot. Also if you're sure that you've installed it, please check it again, there were namely some problems for some people that some of their packages got uninstalled while updating Discord.js to version 13.
For your problem in the comments ("TypeError [CLIENT_MISSING_INTENTS]"), it is now required in Discord.js version 13 to add your needed intents in the client. Please read this part of the Discord.js guide.
I fixed this issue by changing the opened directory of the terminal. Just go to the terminal and type: cd <folder name> until you reach the folder in which your js file is located. Then save and run again.
npm uninstall webpack-cli -D
npm install webpack-cli#3.3.12 --save-dev
than work fine
I went ahead and used npm update in my terminal(hyper) and when I tried to restart my app.js server, I got an error stating
[nodemon] app crashed - waiting for file changes before starting...
I thought I needed to use this command (npm update) in order to update my node modules, but then for some reason, some modules got deleted. ("Error: Cannot find module 'parseurl'"). I'm still a newbie to development and have no clue where to go from here. What to do?
Here's a screenshot of the error in my terminal.
screenshot of error
Nodemon tried to start the server, but it won't start successfully if it can't find the module you are referencing. Try reinstalling "parseurl" npm i parseurl and make sure the path to the module is correct. Once you have done that, the server should start successfully pending any other issues.
There is probably an obvious answer to someone who is more familiar with NodeJS than me but:
When running an application which is using a node-gyp package, it runs without problems using
node ./src/index.js
However running it using a very simple package.json start-script:
"scripts": {
"start": "node ./src/index.js"
}
in npm:
npm start
npm info it worked if it ends with ok
npm info using npm#6.9.0
npm info using node#v11.10.1
npm info lifecycle rosbag2#0.1.0~prestart: rosbag2#0.1.0
npm info lifecycle rosbag2#0.1.0~start: rosbag2#0.1.0
> rosbag2#0.1.0 start /Users/andreasklintberg/personal/xviz/examples/converters/rosbag2
> node ./src/index.js "./src/index.js"
internal/modules/cjs/loader.js:779
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen(/Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node, 1): Library not loaded: #rpath/librosidl_typesupport_cpp.dylib
Referenced from: /Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node
Reason: image not found
And similarly in yarn
yarn start
yarn run v1.13.0
warning package.json: No license field
$ node ./src/index.js ./src/index.js -d ../../../data/rosbag2/rosbag2_2019_03_09-21_54_44 -o ../../xviz-data/rosbag2/rosbag2_2019_03_09-21_54_44/
internal/modules/cjs/loader.js:779
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen(/Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node, 1): Library not loaded: #rpath/librosidl_typesupport_cpp.dylib
Referenced from: /Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node
Reason: image not found
I know the error is because a dynamic link/#rpath is messed up, and I was thinking it was because npm/yarn messes with the env variables or something, but running yarn env it seems everything is correct.
So I guess i'm wondering if anyone know what the difference is running it in native node and using npm/yarnscript to wrap the start? And why this difference messes up the #rpath/dynamic linking ?
Edit:
My index.js file is very simple, just imports the built node-gyp package:
let RosbagDeserializer = require('../build/Release/rosbags2_nodejs.node');
const deserializer = new RosbagDeserializer.Rosbag2Wrapper();
This is the project in question, https://github.com/klintan/rosbag2_nodejs
I would love a more comprehensive answer but at least I solved it with the help of a lot of wonderful commenters:
The #rpath is not set on Mac, but with DYLD_LIBRARY_PATH it works, because that is one of the runtime search paths, it seems (https://superuser.com/questions/282450/where-do-i-set-dyld-library-path-on-mac-os-x-and-is-it-a-good-idea). However for some reason NPM removes this, I'm guessing it has to do with SIP on Mac, or maybe some other security measure that removes this env variable.
DYLD_LIBRARY_PATH is available if you run node index.js but NOT if you are running it using npm start (node index.js start script).
Both #Michal Kapracki and #Avik was hinting at this (I missed the missing env variables when comparing the first time)
What I did to solve it was similar to the dyld: Library not loaded ... Reason: Image not found question as #Avik linked, I had to add a bunch of libraries which were dependent (that was automatically resolved before) and a post_install.sh script which uses the install_name_tool to change the #rpaths to the correct path.
It's a pretty ugly solution https://github.com/klintan/rosbag2_nodejs/blob/master/post_install.sh but it works.
Only for Mac though, so needs to be generalized.
So in summary what I think is the issue:
NPM for some reason can't use or removes the env variable DYLD_LIBRARY_PATH which is used to search for dynamically linked libraries during runtime. This makes it necessary to link these manually using the mac tool install_name_tool.
I'm working through a tutorial on Node.js that begins with a simple authentication program. This is the second time I'm doing this tutorial, and the first time, everything worked fine. However, upon uninstalling node and starting from scratch (installing node.js and express via npm), the instantiation of authentication errors out as below.
program.confirm('destination is not empty, continue? ', function(ok){
^
TypeError: Object #<Command> has no method 'confirm'
at C:\Users\Kyle\AppData\Roaming\npm\node_modules\express\bin\express:251:15
at C:\Users\Kyle\AppData\Roaming\npm\node_modules\express\bin\express:382:5
at Object.oncomplete (fs.js:107:15)
I'm on a windows machine, running Node.js v0.10.20 and express v3.4.1.
Is this a result of the inconsistent -g flag install referenced here?
EDIT: Express initializes apps fine in other directories, even those with the subdirectory Node.js. The path to this problem folder is C:\dev\Node.js\ ...any idea why Express refuses to initialize something in this folder?
Try:
Remove your directory
"C:\Users\Kyle\AppData\Roaming\npm\node_modules\express\node_modules\commander".
Install node module "commander 1.3.2" globally.
Command line: $ npm install -g commander#1.3.2
Run "express" again.
It seems to be the problem referred to the new version(2.0.0) of the commander module.
It works on my mac.
Good luck~
I had the same problem. Rather than fix the problem, you can fix the source of the problem (not specifying an empty directory). In my case I was specifying an empty directory, but it was associating that with the previous switch.
I had to change:
node_modules/.bin/express -s -e -c ./server
To:
node_modules/.bin/express -s -e -c css ./server
Otherwise it thought the server path was the type of css to use and was setting the code path to '.'